Time Out condition


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Time Out condition
# 1  
Old 06-14-2011
Wrench Time Out condition

Hi All,

I need a shell script for getting the input values within a particular time. say for eg. 60 sec. If the user did not give value with in the time limit,then it should display as time out.




Thanks in advance for your kind help Smilie

Last edited by kalai; 06-14-2011 at 07:22 AM..
# 2  
Old 06-14-2011
UPDATE: itkamaraj 's solution below is much more sensible if you are writing a bash script
[strike]Fork and send a sig alarm after 60 from the child then the trap for the sig alarm is to use the default value/terminate with a request to attend the process in future[/strike]

Last edited by Skrynesaver; 06-14-2011 at 06:59 AM..
# 3  
Old 06-14-2011
Quote:
Originally Posted by Skrynesaver
Fork and send a sig alarm after 60 from the child then the trap for the sig alarm is to use the default value/terminate with a request to attend the process in future
Fork command is new to me..
Could u plz show coding for that..



Thanks in advance for your help
# 4  
Old 06-14-2011
man read

check the -t option
# 5  
Old 06-14-2011
Quote:
Originally Posted by itkamaraj
man read

check the -t option
yet i did not get a clear idea there. Smilie
# 6  
Old 06-14-2011
Its something like below..
Code:
#!/bin/ksh
echo "type something.."
read -t 10 var1 # wait for 10 seconds
if [[ -n $var1 ]]
then
        echo "you have entered: $var1"
else
        echo "time is out"
fi

This User Gave Thanks to michaelrozar17 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Condition based on Timestamp (Date/Time based) from logfile (Epoch seconds)

Below is the sample logfile: Userids Date Time acb Checkout time: 2013-11-20 17:00 axy Checkout time: 2013-11-22 12:00 der Checkout time: 2013-11-17 17:00 xyz Checkout time: 2013-11-19 16:00 ddd Checkout time: 2013-11-21 16:00 aaa Checkout... (9 Replies)
Discussion started by: asjaiswal
9 Replies

2. Shell Programming and Scripting

If condition return 0 even when it fails to satisfy te condition

HI My doubt may be basic one but I need to get it clarified.. When i use "if" condition that checks for many AND, OR logical conditions like if ]; then return 0 fi Even the if condition fails it returns as zero.. Any clue.. But if i add else condition like if ]; ... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

3. Shell Programming and Scripting

Time condition exit loop

Hi All, Requirement: The below script should automatically exit at 6pm everyday without manually killing the script Tried running with the below shell script but found the script was still running when the time was 6:15pm. The script did not exit the while loop at 6pm The script runs... (6 Replies)
Discussion started by: a1_win
6 Replies

4. Solaris

modifying date and time and time zone on solaris 5.10 with (redundant server) veritas

I have a cluster of two Solaris server (veritas cluster). one working and the other is standby I am going to change the date on them , and am looking for a secure solution as it is giving an important service. my opinion is that the active one doesn't need to be restarted (if I don't change the... (1 Reply)
Discussion started by: barry1946
1 Replies

5. Shell Programming and Scripting

redirect stdout echo command in condition A run in condition B

hi, I have some problems in my simple script about the redirect echo stdout command inside a condition. Why is the echo command inside the elif still execute in the else command Here are my simple script After check on the two diff output the echo stdout redirect is present in two diff... (3 Replies)
Discussion started by: jao_madn
3 Replies

6. Programming

sql query to match condition from other table (time sensitive)

I know little SQL and could really use a hand here. I need to get the fields last_name, first_name and email from the table users and only if the entery with the same pkey in the table addresses, in the city column is Seattle. So if the city in the addresses table is Seattle, go to the table... (2 Replies)
Discussion started by: computethis
2 Replies

7. HP-UX

Difference between [condition] and [[condition]] and ((condition)) when used with if condition

Executed the following if conditions .. and got different results . only (( )) gave correct o/p with all scenarios . Can anybody please let me know what is the difference between and ] and ((condition)) when used with if condition. And why each condition gave different result. 1.... (2 Replies)
Discussion started by: soumyabubun
2 Replies

8. Shell Programming and Scripting

If(Condition) Rename a file with (Date+Time) Stamp

Hi! Please see our current script: #!/usr/bin/ksh if (egrep "This string is found in the log" /a01/bpm.log) then mailx -s "Error from log" me@email.com, him@email.com </a01/bpm.log fi To the above existing script, we need to add the following change: 1) After finding the string,... (7 Replies)
Discussion started by: atechcorp
7 Replies

9. Shell Programming and Scripting

Convert Epoch Time to Standard Date and Time & Vice Versa

Hi guys, I know that this topic has been discuss numerous times, and I have search the net and this forum for it. However, non able to address the problem I faced so far. I am on Solaris Platform and unable to install additional packages like the GNU date and gawk to make use of their... (5 Replies)
Discussion started by: DrivesMeCrazy
5 Replies

10. UNIX for Advanced & Expert Users

How To Provide Time Sync Using Nts-150 Time Server On Unix Network?

can anybody tel lme,how to instal NTS -150 on a unix network,it needs some patch to fetch time frm serve,,?? (2 Replies)
Discussion started by: pesty
2 Replies
Login or Register to Ask a Question