running command in while loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting running command in while loop
# 1  
Old 11-21-2007
running command in while loop

I have a script that users a while read, whithin this I want to execute the cp -i command on some of the results, however because it is in a loop it skips the -i part of cp. How do I get the loop to stop each time cp -i is run and wait for the user to type the response.
# 2  
Old 11-21-2007
explicitly redirect the input from tty

something like this

Code:
while read line
do
cp -i test test2 < /dev/tty
done < file

# 3  
Old 11-21-2007
Thanks very much, works a treat!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Running in a loop in UNIX

I have a table in oracle which has 2 columns table_name table_name1 U1 T1 U2 T2 I have to take these as a variable in unix and then go to /home/bin and execute a unix command using these variables. Considering that there is only one row in the table I was able to write the below but need help... (2 Replies)
Discussion started by: Ashcalin
2 Replies

2. Shell Programming and Scripting

While loop is running only for the first iteration

Hello, I've written a script to automate encoding of all the MP4 files in a directory (incl. subdirectories). But unfortunately it's running for the first MP4 file only. My machine details: root@Ubuntu16:~# uname -a Linux Ubuntu16 4.10.0-28-generic #32~16.04.2-Ubuntu SMP Thu Jul 20 10:19:48... (2 Replies)
Discussion started by: prvnrk
2 Replies

3. Shell Programming and Scripting

Select command going to infinite loop after running the script

cd /opt/et/WAS/apps/8.0 find . -name "HostIntegration.properties" -o -name "HostSocket.properties" -o -name "environment.properties" 2> /dev/null | awk -F '' '{print $4}'|awk '!x++' | cat>/home/cbadmin/file1.txt cd /home/cbadmin/ PS3='Please enter a number from list of applications==>:' select... (3 Replies)
Discussion started by: bhas85
3 Replies

4. Shell Programming and Scripting

While Loop not running

echo "The recreate was successfully completed for device file $LCL_CLN_FILE." >> $LOG_FILE remaining=$(symclone -sid $LCL_SID -f $ETC/$LCL_CLN_FILE query | grep MB | awk '{print $2}') if then while do echo "$remaining MB's to be copied........." >> $LOG_FILE ... (10 Replies)
Discussion started by: rajsan
10 Replies

5. Shell Programming and Scripting

Running binnary program in a loop

I am using a very simple script (MUS) to process some files where the input file for the binary application I am running has to be named infile. So I have this: #!/bin/bash for i in {1..n} do mv block${i} infile done ./dnadist <<EOF D Y EOF However, I want to use dnadist inside the... (3 Replies)
Discussion started by: Xterra
3 Replies

6. Shell Programming and Scripting

Help Running Loop Script

Hi I have a file called lastlogin_1 that contains a list of usernames. I would like to put together a quick loop script that will use a variable (the contents of lastlogin_1 file) and grep all directories and sub directories in the current directory (/in/the/current/directory) for each username... (3 Replies)
Discussion started by: jamba1
3 Replies

7. Shell Programming and Scripting

Running for loop on remote server

Hi, I'm having a problem performing for loop on remote server, i know this can be done with one liner but i'm not sure how it works if using logical operator such as for ifs and case or while for server in sterverA serverB serverC ; do ssh -v $server "cd ~/MyDocuments/; bag=`find... (6 Replies)
Discussion started by: sexyTrojan
6 Replies

8. Shell Programming and Scripting

For loop and running 2 commands at once?

HI. I am trying to run 2 commands, using the "for x in a b c d" loop but i am having a hard time coding it... Here is what i have so far: for SERVER in SERVERA SERVERB SERVERC SERVERD SERVERE do ############################################################################### #... (5 Replies)
Discussion started by: Stephan
5 Replies

9. Shell Programming and Scripting

loop when process running

Hi Gurus, Could you please help me to create a shell script that will be started by a cron job once every night at 24.00 h (that should bee easy:)) The shell script should control every 30 seconds the name of a process, and when the process doesn't run anymore it should execute a few further... (12 Replies)
Discussion started by: blackwire
12 Replies

10. UNIX for Dummies Questions & Answers

until loop : running even if condition is satisfied

I am checking one until loop with the following logic until || |||| do sleep 30 done before running this i am exporting above variables to SUCCESS.But the loop is running in infinite loop.My requirement is to make the loop run until all the 3 variables are SUCCESS or any of the 3... (2 Replies)
Discussion started by: dr46014
2 Replies
Login or Register to Ask a Question