LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 03-09-2006, 12:28 PM   #1
WindowBreaker
Member
 
Registered: Oct 2005
Distribution: Slackware
Posts: 228

Rep: Reputation: 40
script 'prompting with timeout' question


I know how to have a bash script prompt a user and save it in a variable.

Code:
#!/bin/sh
echo -n "Please enter your name: "
read $NAME
The question is how to do so with a timeout period (let's say 5 seconds), after which the variable can receive some default value.

Thanks for any suggestions.
 
Old 03-09-2006, 12:37 PM   #2
dive
Senior Member
 
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,467

Rep: Reputation: Disabled
NAME="somedefault"
read -t secs NAME

If NAME has a value before prompt and timeout occurs it will keep same value

Last edited by dive; 03-09-2006 at 12:38 PM.
 
Old 03-09-2006, 12:44 PM   #3
WindowBreaker
Member
 
Registered: Oct 2005
Distribution: Slackware
Posts: 228

Original Poster
Rep: Reputation: 40
Dive:
Thanks for the reply. I tested it and it works great.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Socket timeout (c question) alaios Programming 13 09-11-2005 11:43 AM
Question on FTP 421 no transfer timeout enjoyzj Linux - Networking 2 06-04-2004 10:24 AM
Wireless hotspot client timeout script Joffe Linux - Wireless Networking 0 04-14-2004 10:12 AM
PHP script timeout J_Szucs Linux - Software 4 01-22-2004 04:10 PM
scripting help: boot script, loopback password, timeout undecipherable Programming 3 12-18-2002 10:15 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:47 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration