sending control c in the loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting sending control c in the loop
# 1  
Old 05-04-2007
sending control c in the loop

I want to go through the list of items and run it.

while running it, some of them will have either

>there is no response # and then end it... so that it can go to next item

OR

>there is response # but in order to break out of it, u need to do Control c.

How do you send control c within loop?

Please help.

thanks.
# 2  
Old 05-04-2007
come out of loop?

If you want to come out of loop, use either break or exit
# 3  
Old 05-04-2007
not exit out of the loop.. basic mechanic of the program should be,

for N in a b c d e f g h i j k
do
for X in 1 2 3 4 5 6 7 8
do
output=$(someprogram $X@$N)
if [ $output -eq whatever ] ; then
echo "$X@$N is $output"
else
echo "$X@$N is NOT whatever"
fi
done
done

Problem is, this someprogram that I am running so that it will either spit out
1)whatever OR 2)some other response but in order to quit from that program, you need to do control c

a)where do I put control c statement in the script
b)and more importantly, HOW do I send control c from shell script..
# 4  
Old 05-04-2007
Dont understand

I dont understand by what you mean by quitting from the script. But you can send an interrupt signal by
Code:
kill -2 pid

Check
Code:
kill -l

for all signals.
I am still not clear of your requirement. Sorry about that. Smilie
# 5  
Old 05-04-2007
output=$(someprogram $X@$N)

when above is ran,

above program will spit out either of below outputs

Connected to someprocess@host3
>type message
> <--- since we are just seeing whether we can connect to this process, we will quit this bye
doing control C

OR

Cannot connect: connection refused


OR maybe I am just doing a wrong thing with shell script.. maybe I need to run Expect??

Please advise.
# 6  
Old 05-04-2007
How would you know when to send the ctrl-c (SIGINT) to the child process?

How does the child process (the one you are want to kill) normally quit?
# 7  
Old 05-04-2007
Once again,

Connected to someprocess@host3
>type message
> <--- since we are just seeing whether we can connect to this process, we will quit this bye
doing control C

OR

Cannot connect: connection refused


If I was doing this interactively,

I would type

./program process.1@host13

IF process.1 was doing what's it suppose to be doing, i would see

Connected to someprocess@host3
>type message
>

and I can type command and do stuff... and only way to quit out of that is to do control-C
But if you do get above message it means from my host to that process on host3, I am able to communicate and that's what I am trying to find out

If process.1 was not up, than I would see

Cannot connect: connection refused

and it will give me back the prompts.


Please let me know if needs more info..
I am just not sure if sending control c within loop is possible in the script or not
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing a control file loop

Hi, Let's say I have a control file like this: RHEL apple "echo apple" RHEL bravo "ls -l bravo*" RHEL church "chmod church.txt" SUSE drive "chown user1 drive.txt" SUSE eagle "echo "eagle flies"" SUSE feather "ls -l feather*" HP-UX google "sed 's/^Google.*$/&\ ACTION: go to... (14 Replies)
Discussion started by: The Gamemaster
14 Replies

2. Shell Programming and Scripting

awk loop using array:wish to store array values from loop for use outside loop

Here's my code: awk -F '' 'NR==FNR { if (/time/ && $5>10) A=$2" "$3":"$4":"($5-01) else if (/time/ && $5<01) A=$2" "$3":"$4-01":"(59-$5) else if (/time/ && $5<=10) A=$2" "$3":"$4":0"($5-01) else if (/close/) { B=0 n1=n2; ... (2 Replies)
Discussion started by: klane
2 Replies

3. Shell Programming and Scripting

Array Variable being Assigned Values in Loop, But Gone when Loop Completes???

Hello All, Maybe I'm Missing something here but I have NOOO idea what the heck is going on with this....? I have a Variable that contains a PATTERN of what I'm considering "Illegal Characters". So what I'm doing is looping through a string containing some of these "Illegal Characters". Now... (5 Replies)
Discussion started by: mrm5102
5 Replies

4. Shell Programming and Scripting

Loop exit control

Hi I would like to exit the loop below on <Enter> even if it sleeps. Is it possible? while true do my_procedure; sleep 60 done Thanks (7 Replies)
Discussion started by: zam
7 Replies

5. Shell Programming and Scripting

Using variables created sequentially in a loop while still inside of the loop [bash]

I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends. As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Discussion started by: DeCoTwc
2 Replies

6. UNIX for Dummies Questions & Answers

For loop control with two variables in csh shell

Hi All How can i control for loop with two different variables in csh shell Regards Nikhil (1 Reply)
Discussion started by: Nikhilindurkar
1 Replies

7. Shell Programming and Scripting

Control Not Coming Out Of While Loop

I have an empty .gz file in archival directory. And I am redirecting to a dat file. My while loop is not getting ended. I need the solution. cnt=0 while read line do cnt=`expr $cnt + 1` echo "$ARCH_DIR/$line.gz" >> $DATA_DIR/$FILE_LIST_FILE_FEB FILE_NAMES=${FILE_NAMES}"... (2 Replies)
Discussion started by: vinodh1978
2 Replies

8. Shell Programming and Scripting

for loop control

Hi, I have taken a piece of code from a book, which is working as per the specification. The code.... for entry in * do if then echo $entry fi done The sub-directories present in the current directory will be displayed while executing. ... (3 Replies)
Discussion started by: saravanakumar
3 Replies

9. Shell Programming and Scripting

find command in while loop - how to get control when no files found?

I have the following statement in script: find ${LANDING_FILE_DIR}${BTIME_FILENAME_PATTERN2} -print | while read file; do ... done When there are no files located by the find comand it returns: "find: bad status-- /home/rnitcher/test/....." to the command line How do I get control in... (3 Replies)
Discussion started by: mavsman
3 Replies

10. UNIX for Dummies Questions & Answers

Sending control sequence to printer before job

I am having difficulty sending a control sequence ESC&l5H (print to middle tray) to a HP printer (lp4).It is ignoring the command. I am using the following syntax in an executable file : echo "'/033'&l5H" > /dev/lp4 lp -dlp4 filename a) Is /033 'escape' ? b) What is the correct syntax ? (5 Replies)
Discussion started by: ianc
5 Replies
Login or Register to Ask a Question