The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how other user cannot read my script? happyv Shell Programming and Scripting 19 10-02-2006 11:01 AM
Script not waiting for user responce rdudejr Shell Programming and Scripting 3 07-05-2006 11:20 AM
need to read a file and keep waiting till it satisfies some condition senthilk615 Shell Programming and Scripting 1 03-22-2006 03:15 AM
booting up but the system was waiting for user interaction at console stancwong UNIX for Dummies Questions & Answers 1 11-29-2005 11:51 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-11-2003
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
read-waiting for user response

Would there be any reason for why a 'read ans' would not wait for a user's response (i.e user has to hit a key to continue)? I know for sure that it is doing everything else in that part of my 'if' statement but it doesn't wait for me to hit a key before continuing.

The strange thing is that for ans1 - ans3, it waits, then beginning with ans4 - ans7, it just continues as if I had hit a key and I've put breakpoints in but can't figure it out.

I'm not sure what would cause this anomaly. I've written many interactive scripts (ksh) with over 5-10 prompts in them and they've always worked fine.

I just can't figure out what could cause this one to be so different that it would ignore the wait prompt (read ans4). The code is identical to how I got ans1 - ans3 so I'm just wondering if any of you know/heard of this...this script has lots of validation going on using regexp, grep, etc to validate fields in a file but this should not be causing my problem....
  #2 (permalink)  
Old 05-12-2003
Cameron's Avatar
Cameron Cameron is offline Forum Advisor  
Registered User
  
 

Join Date: Nov 2001
Location: Brisbane, Australia
Posts: 499
Is it possible for you to post your script?? It does sound weird.
  #3 (permalink)  
Old 05-12-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
It's impossible to say what is happening without looking at the script. But you have probably redirected stdin at the time that the "read" statement is executed. Try something like:

read ians4 < /dev/tty
  #4 (permalink)  
Old 05-12-2003
giannicello giannicello is offline
Registered User
  
 

Join Date: Sep 2001
Location: Phoenix
Posts: 169
Thanks! That did it. All is working now. So is this the most definite way to ensure that the user is prompted?

As soon as I added the < /dev/tty, all my prompts worked as they should at specified points.

Is it good practice then to always do this for every read statement in an interactive script?
Would there be a reason why one should not use the redirection every time?

Gianni
  #5 (permalink)  
Old 05-12-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
The " < /dev/tty" opens the file called /dev/tty and attaches it to stdin. That is an expensive operation. You don't want to do that needlessly.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0