Script not waiting for user responce


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script not waiting for user responce
# 1  
Old 07-05-2006
Script not waiting for user responce

hi all,

Im fairly new to scripting and am having a noobish issue. Ive got a script that checks for certain directories and if they dont exist, prompts the user to do a mkdir. heres trouble spot in the script:


cat dirlsttemp.dat | while read dir; do

echo "$dir does not exist, would you like to create it now? (y or n)"
read responce
if [ $responce == "y" ];

then
mkdir $dir

else
echo "$dir has not been created"
fi
done
fi

what essentially happens is it does not wait for the responce and goes right to the else. i believe it has something to do with reading from the cat...but I dont know any other way to read that file line by line. Any solutions?
# 2  
Old 07-05-2006
Code:
#!/bin/ksh

for dir in $(< dirlsttemp.dat); do

    echo "$dir does not exist, would you like to create it now? (y or n)"
    read responce
    if [ $responce == "y" ]; then
       mkdir $dir
    else
       echo "$dir has not been created"
    fi
done

# 3  
Old 07-05-2006
Try this

for input_dir_row in `cat dirlsttemp.dat`
do

if [ -d $input_dir_row ]
then
echo "$input_dir_row exist"
else
echo "$dir does not exist would you like to create it now y or n"
read entry

if [ $entry -eq "y" ]
then
mkdir $input_dir_row
fi
fi
done
# 4  
Old 07-05-2006
thanks guys, that worked beautifully
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell read command is not waiting for user input

Hi, i am working on one automation , for that i have writing one shell program that take user input in "while read line" block. but read command is taking value that is readed by While block. while read line; do command 1; command 2 echo -n "Do you want to continute > " read rsp... (2 Replies)
Discussion started by: ranvijaidba
2 Replies

2. Shell Programming and Scripting

Waiting for a process to complete in shell script

Hi, I need to initiate a process script which will start and do some processing and then shuts down. Then i need to other verifications. But the the process takes around 25 to 3o minutes. One thing i can monitor the nohup.out file for this process where i can wait for shutting down statement to... (3 Replies)
Discussion started by: Prashanth19
3 Replies

3. Windows & DOS: Issues & Discussions

AutoSys Job not waiting for script to complete

I'm not sure if this is the right place to post this issue...but here goes... I am converting a set of windows jobs from Control-M to AutoSys r11.3. The same command line is being executed in both systems. The Control-M job runs to compltion in about 1.5 hours, waiting for the entire batch... (3 Replies)
Discussion started by: ajomarquez
3 Replies

4. Shell Programming and Scripting

how to grep the responce on TL1

Hi All, I'm a newbie here.. how can i grep the data when i receive responce from TL1 example: responce from TL1: blabalbalbalbalba.,lbalba,SUCCESFULL,blahblahbalabh... how can i grep the "SUCCESSFULL" while i'm running the script? is it possible? because i'm only to know is if... (2 Replies)
Discussion started by: nikki1200
2 Replies

5. Shell Programming and Scripting

SQL PLUS Command 'ACCEPT' is not waiting for user input with sh shell script

Dear All, The sqlplus 'Accept' command is not waiting for user input when I include the command within a shell script. Note: The 'Accept' command is working fine if I execute it in a SQLPLUS Prompt. Please fins the below sample script which i tried. SCRIPT: -------- #!... (4 Replies)
Discussion started by: little_wonder
4 Replies

6. Shell Programming and Scripting

expect script hangs while waiting for the flag...

I am writing a script to check whether the root password is set to a special string on some solaris servers. Normally, the manually ssh login session is as below: $ ssh root@host1 Password: Last login: Wed Sep 16 13:53:28 2009 from 10.1.102.13 Sun Microsystems Inc. SunOS 5.10 ... (4 Replies)
Discussion started by: sleepy_11
4 Replies

7. UNIX for Advanced & Expert Users

Script Not waiting....plz help

Hi All: I am trying to call a multi-step script from a script. here is the code #!/usr/bin/ksh util.sh <<EOF connect dump EOF I am able to run the script but it is disconnecting before the dump job is finished. The script util.sh does not provide any functionality to wait... (9 Replies)
Discussion started by: laxman123
9 Replies

8. Shell Programming and Scripting

Help with script, shutdown if no ping responce

Hi, i would like to create a script that shuts down the system if the power fails, basicly the solaris box would load the script at startup. Ping 192.168.1.100 every 20 secs If cannot get responce 3 times in a row send init 0 to the system. Simple but effective, as 192.168.100.1 wont be on... (39 Replies)
Discussion started by: ringofsteel
39 Replies

9. UNIX for Dummies Questions & Answers

booting up but the system was waiting for user interaction at console

Hi all, My ssytem is mounted on a rack and not connected with any console. When I rebooted it remotely, it didn't go thru the bootup process. when I connect my laptop to the system locally and found that it was waiting for user interaction. Do you know how to disable it, so that it will boot... (1 Reply)
Discussion started by: stancwong
1 Replies

10. Shell Programming and Scripting

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... (4 Replies)
Discussion started by: giannicello
4 Replies
Login or Register to Ask a Question