Timed read command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Timed read command
# 1  
Old 08-25-2007
Timed read command

Hi guys,

I love unix....but i also hate it Smilie

I want to write a script that will pause in the middle ask for user input, but if no input is given i want the script to continue anyway.

Say ask a question and give 1 min to answer and if no answer at all the script continues.
# 2  
Old 08-25-2007
Hi.

If you are using bash, then an option of interest for you is:
Code:
read -t 10 ... (other arguments)

for a 10-second limit. See man bash for details on the read statement.

Other shells may require separate functions to accomplish that task ... cheers, drl
# 3  
Old 08-26-2007
Thanks Smilie

this is what i came up with in the ned, works like a dream.

answer="No";read -p "Do you want to exit? Answer y to exit. " -t 30 answer;echo " Your answer is $answer";
if [ "$answer" = "y" ];then
echo "you have chosen to exit."
break
else
echo ""
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Command timed out implementation

I have a running service which runs in background. It execute shell commands by function system(cmd) I need to report fail when command execution takes more than 60 seconds. Parent doesn't need to wait for 60 seconds of time if the cmd execution completed already. runCommand() { pid_t... (3 Replies)
Discussion started by: techmonk
3 Replies

2. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

3. UNIX for Dummies Questions & Answers

read command - using output from command substitution

Hey, guys! Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek: So, I wanted to use a command statement similar to the following. This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies

4. Shell Programming and Scripting

Timed Scripts

Hi all I need a little bit of help, i am looking for a script that can have different events in it and then if it is a certain day email me about it some sort of email reminder system any ideas thanks (4 Replies)
Discussion started by: ab52
4 Replies

5. Solaris

RCP command timed out

I HAVE A PERL SCRIPT WHICH RCP files from one server to another. The script is not having any issues for years and it is running for more than 3 years . Last week it had failed with error "Command timed out " error. Please help me out (3 Replies)
Discussion started by: praviper
3 Replies

6. Solaris

I/O timed out

I have Ultra 45 Sun solaris box with Solaris 10 installed. My problem is when i boot the unix box, i got the message: What does this message meant? then it does not continue to boot successfully. Please help. Thanks in advance. (5 Replies)
Discussion started by: etcpasswd
5 Replies

7. Programming

Timed wait?

Is there any way in which I can make my wait signal to wait for a specified time for child job to complete. And if that time is over, the program gets out of the wait signal to process other things (4 Replies)
Discussion started by: anjul_thegreat
4 Replies

8. HP-UX

connection timed out

I am trying to connect with my hp machine using "dialup networking." It times out after 30 seconds. Is there a way to adjust this time. Would it have anything to do with rexec? thanks (0 Replies)
Discussion started by: paschal
0 Replies

9. UNIX for Dummies Questions & Answers

timed commands

Hello, How can I set up events to be executed at a certain time? And do I need some kind of privilege such as being in cron group? (2 Replies)
Discussion started by: rayne
2 Replies

10. UNIX for Advanced & Expert Users

Connection Timed out

I connect to a Sun Box through telnet but it timed out in couple of minutes. Advance thanks for any idea...help... (2 Replies)
Discussion started by: s_aamir
2 Replies
Login or Register to Ask a Question