the shell not pause when execute read command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting the shell not pause when execute read command
# 1  
Old 07-03-2008
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 05:14 AM..
# 2  
Old 07-03-2008
Maybe silly question :
Why "printf "Please ..."
All your other lines, you used echo...
# 3  
Old 07-03-2008
Quote:
Originally Posted by vbe
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  
Old 07-03-2008
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  
Old 07-03-2008
Quote:
Originally Posted by vbe
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 Smilie... Thanks
# 6  
Old 07-03-2008
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  
Old 07-03-2008
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Process to read a new file entry and execute a command

I need to develop a process/daemon which will constantly monitor a file for new entry and execute a command. for eg, there is a file /var/log/inotify.log When a new entry like below gets appeneded to this file, execute the command as follows. /home/user/public_html/bad.php|CREATE ... (2 Replies)
Discussion started by: anil510
2 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. Shell Programming and Scripting

When i am trying to execute export command within a shell script it is saying command not found.

I am running the export command within a view to use that value inside my build script. But while executing it it is saying "export command not found" My code is as follows: -------------------------- #!/bin/sh user="test" DIR="/bldtmp/"$user VIEW="test.view1" echo "TMPDIR before export... (4 Replies)
Discussion started by: dchoudhury
4 Replies

4. UNIX for Dummies Questions & Answers

How to execute command after telneting in shell script?

Hi , I have to write a shell script to telnet to specific host and execute the admin command there. Please help me to do that. Eg : telnet hostname portno admin command exit (3 Replies)
Discussion started by: arukuku
3 Replies

5. Shell Programming and Scripting

How to pause a shell script

Hi, I've written a shell script to take photos with my camera. After every picture taken, the picture is transmitted to the computer via usb and then deleted on the camera. But sometimes there's an error and the picture is not deleted and so, after a certain time, the camera chip will be... (4 Replies)
Discussion started by: McLennon
4 Replies

6. Shell Programming and Scripting

Cann ot execute a shell command

Hi , I am new to UNIX and Shell scripting . I am not able to execute a shell file . I try to do it using the below command. ./start.sh but it shows an error that 'cannot execute ' what might be the reason for this? pls help me to resolve it. (1 Reply)
Discussion started by: Deepakkumard
1 Replies

7. Shell Programming and Scripting

shell script to execute user command

I don't know why the following shell script doesn't work. Could you please help me out? #!/usr/bin/ksh test="cal > /tmp/tmp.txt 2>&1" $test I know it will work for the following format: #!/usr/bin/ksh cal > /tmp/tmp.txt 2>&1 However, I need to get the command from the user in... (1 Reply)
Discussion started by: redtiger
1 Replies

8. Shell Programming and Scripting

execute a command silently or quietly within a shell

How do I suspend output of commands and tools that sometimes utter unwanted output? I know that I can always pipe to null or some such thing, but is there a simpler more elegant (i.e. accepted) practice? (4 Replies)
Discussion started by: lumix
4 Replies

9. UNIX for Dummies Questions & Answers

pause needed for corn shell

I need a user pause for a script file, like the pause command in dos. please help I thought it was the corn shell it is csh. (7 Replies)
Discussion started by: dennysavard
7 Replies

10. Shell Programming and Scripting

execute shell command in perlscript

Hi I have this below script...I want to execute the shell command "rm" in the below script but it is not working. Can anybody why so? I got the below error rm: /users/amvarma is a directory sh: /*-log*: not found ------------------- $u=`whoami`; print "$u\n"; $op_1=$ARGV; # for... (0 Replies)
Discussion started by: amitrajvarma
0 Replies
Login or Register to Ask a Question