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
shell script to execute user command redtiger Shell Programming and Scripting 1 04-30-2008 06:53 PM
execute a command silently or quietly within a shell lumix Shell Programming and Scripting 4 12-15-2007 03:10 PM
pause needed for corn shell dennysavard UNIX for Dummies Questions & Answers 7 12-09-2007 02:16 PM
execute shell command in perlscript amitrajvarma Shell Programming and Scripting 0 11-27-2007 02:49 AM
Urgent!! How to write a shell program to execute command to access internet? firebirdonfire UNIX for Dummies Questions & Answers 2 04-26-2001 11:16 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-03-2008
neruppu neruppu is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 13
the shell not pause when execute read command

Hi, i facing a problem when run the script below..


while [ -z "$ea_ident" -o -n "`grep 2>/dev/null \"^EA $ea_ident$\" $EA_run_file`" ]
do

if [ $all_OMC -ne 1 ]
then
printf "Please enter a name : [${omc_ident}] "
read response # the problem occur here

if [ -z "$response" ]
then
ea_ident=${omc_ident}
else
#
# Check that name does not contain invalid characters
#
ea_ident=`echo $response | tr -d "/ \011"`

if [ -z "${ea_ident}" -o "${ea_ident}" != "${response}" ]
then
echo
echo "Sorry, not a valid name!"
echo "Must not contain spaces, tabs or '/'."
echo
ea_ident=
fi
fi
else
ea_ident=${omc_ident}
fi


if [ -n "`grep 2>/dev/null \"EA $ea_ident$\" $EA_run_file`" ]
then
echo "That name is already in use."
fi

done



$ea_ident is a data , when get into the loop, when excute read command, shell suppose to pause and wait for user input...

But in my case, its not and straight away execute the
next statement -> if [ -z "$response" ] ,

i did try to use </dev/tty but yet still no use..

Please post me any solution for this... Thanks

Last edited by neruppu; 07-03-2008 at 04:14 AM..
  #2 (permalink)  
Old 07-03-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,546
Maybe silly question :
Why "printf "Please ..."
All your other lines, you used echo...
  #3 (permalink)  
Old 07-03-2008
neruppu neruppu is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 13
Quote:
Originally Posted by vbe View Post
Maybe silly question :
Why "printf "Please ..."
All your other lines, you used echo...

I just simply put it..
but i dont think it will cause this problem...
  #4 (permalink)  
Old 07-03-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,546
How can you be sure you entered in the loop?

Im pretty sure if I put:

printf "Please enter a name : [${omc_ident}] "
read response # the problem occur here

in a script, it would display and prompt for answer
  #5 (permalink)  
Old 07-03-2008
neruppu neruppu is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 13
Quote:
Originally Posted by vbe View Post
How can you be sure you entered in the loop?

Im pretty sure if I put:

printf "Please enter a name : [${omc_ident}] "
read response # the problem occur here

in a script, it would display and prompt for answer

actually in my scritps, i did follow the flow by put echo messages
and it was entered the loop
and execute both printf and read command, but it didnt pause for user input..

do u have any idea,how to solve this problem ... Thanks
  #6 (permalink)  
Old 07-03-2008
vbe's Avatar
vbe vbe is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2005
Location: Switzerland - GE
Posts: 1,546
ant:/home/vbe/scripts $ all_OMC=2
ant:/home/vbe/scripts $ if [ $all_OMC -ne 1 ]^Jthen^Jprintf "Please enter a name : [>
Please enter a name : []

It does works...
So I believe it before and you dont enter the condition...
Why not try with sh -x ?
  #7 (permalink)  
Old 07-03-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
Your code seems to work fine for me as well, both on Linux and HP-UX.

How are you actually running this script? In what shell and on what OS?
Sponsored Links
Closed Thread

Bookmarks

Tags
linux, solaris

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 02:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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