Click here to Skip to main content
15,910,661 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hello,

I'm writing a script which it has to perform some other steps after a given time.

The thing is I need user to input that time.

My code is :

echo "Enter time you need to disable log:"
read fname2

sleep ($fname2)m

But this not worked for me giving me the following error.

line 26: `sleep ($fname2)m

Can someone please advice me how to get this user input value.

Regards,
Buddhima.
Posted
Comments
Zoltán Zörgő 11-Sep-13 14:27pm    
which shell? bask, csh, ksh?
Strider87 11-Sep-13 18:01pm    
Thank you for your solution but I need to run this sleep process in background of the program.
Zoltán Zörgő 12-Sep-13 5:27am    
Seleep in background???
Strider87 12-Sep-13 15:36pm    
#!/bin/bash

echo "Enter e-mail of requester:"
read fname1

echo "Enter number hours to enable debug :"
read fname2

#shopt -s nullglob
#rm -rf /rezsystem/rezadmin/Log4J/node1/log4jstat.txt
#echo enable > /rezsystem/rezadmin/Log4J/node1/log4jstat.txt

#Debug enable start

#cp /rezsystem/rezadmin/Log4J/Logs/Debug_Mode/Jboss_Conf/node1/log4j.xml /rezsystem/jboss/jboss1/server/default/conf
#cd /rezsystem/jboss/jboss1/server/default/conf
#chown rezuser log4j.xml
#chgrp rezuser log4j.xml
#chmod 775 log4j.xml

#find /rezsystem/jboss/jboss_1/server/default/deploy/ -name "log4j.xml" -type f -exec sed -i 's/priority value="WARN"/priority value="DEBUG"/' {} \;
#find /rezsystem/jboss/jboss_1/server/default/deploy/ -name "log4j.xml" -type f -exec sed -i 's/param name="Threshold" value="WARN"/param name="Threshold" value="DEBUG"/' {} \;

echo "" | mail -s "This is to inform that ONS has enabled DEBUG in Node2 log4j - "$(hostname) $fname1 < /tmp/email.txt

#Debug enable stop

#Jboss Start

#NOWDATE=$(date +"%m-%d-%Y_%H%M")
#zip /var/log/rezg/sys/server1.log_$NOWDATE.zip /var/log/rezg/sys/server1.log
#zip /var/log/rezg/app/rezg_app1.log_$NOWDATE.zip /var/log/rezg/app/rezg_app1.log

#cd /rezsystem/jboss/jboss1/server/default
#rm -r -f work/
#rm -r -f tmp/
#cd /rezsystem/jboss/jboss1/bin
#./run.sh &

#Jboss started

sleep ${fname2}m

#Debug disable start

#cp /rezsystem/rezadmin/Log4J/Logs/Live_Mode/Jboss_Conf/node1/log4j.xml /rezsystem/jboss/jboss1/server/default/conf
#cd /rezsystem/jboss/jboss1/server/default/conf
#chown rezuser log4j.xml
#chgrp rezuser log4j.xml
#chmod 775 log4j.xml

#find /rezsystem/jboss/jboss1/server/default/deploy/ -name "log4j.xml" -type f -exec sed -i 's/priority value="DEBUG"/priority value="WARN"/' {} \;
#find /rezsystem/jboss/jboss1/server/default/deploy/ -name "log4j.xml" -type f -exec sed -i 's/param name="Threshold" value="DEBUG"/param name="Threshold" value="WARN"/' {} \;

#echo disable > /rezsystem/rezadmin/Log4J/node1/log4jstat.txt

#Debug Disable stop

#Jboss Start

#NOWDATE=$(date +"%m-%d-%Y_%H%M")
#zip /var/log/rezg/sys/server1.log_$NOWDATE.zip /var/log/rezg/sys/server1.log
#zip /var/log/rezg/app/rezg_app1.log_$NOWDATE.zip /var/log/rezg/app/rezg_app1.log

#cd /rezsystem/jboss/jboss1/server/default
#rm -r -f work/
#rm -r -f tmp/
#cd /rezsystem/jboss/jboss1/bin
#./run.sh &

echo "" | mail -s "OnS has disabled Debug for Node 1 - "$(hostname) $fname1

Above is my code. Since this it has a sleep command during the execution of this script it holds without coming to the prompt. so at that time no one can work on that terminal. So I need run this sleep process in background.

1 solution

Use: sleep ${fname2}m
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900