adding a kill or ctrl C into script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting adding a kill or ctrl C into script
# 1  
Old 09-26-2012
adding a kill or ctrl C into script

Hi,

The point of this script is to run the same command on multiple of host. This was originally to run some audit scripts on the hdisk on the systems but on some there are a lot of hdisk. is there a way to kill the command from running and let it continue to run the command in the background? this is for a AIX system if that makes a difference.

I essentially want it to just run the command and move onto the next system while the command is actually still running on that same system.

Here's what I have so far:

Code:
#!/bin/ksh

HOSTLIST="<List of host>"
DELAY=3
print -n Enter Command to process on remote Host -
read CMD
print
exec 4>&1

for HOST in $HOSTLIST ; do
echo "running ${CMD} on ${HOST}:"
ssh -t -t $HOST >&4 2>/dev/null |&
sleep $DELAY
print -p /usr/bin/nohup ${CMD}
print -p exit
wait
echo "$CMD completed on ${HOST} !"
done

exit 0

# 2  
Old 09-26-2012
you can run script in background. and it will killed automatically after its operation .

but from your script it looks like user has to provide some data to the script.
# 3  
Old 09-27-2012
Quote:
Originally Posted by pamu
you can run script in background. and it will killed automatically after its operation .

but from your script it looks like user has to provide some data to the script.
yes using ssh it sends the command i tell it to and it should be stopping and moving onto the next one but it doesn't.
# 4  
Old 10-01-2012
anyone?
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Automation of keyboard inputs..like Ctrl+d and Ctrl+a

Hi..! I'm stuck with my automation of starting a process and keeping it running even after the current ssh session has exited.. So i'm trying to use command 'screen'. which is doing exactly what i wanted, But the problem is automation of the same. i will have to press Ctrl+a and Ctrl+d for... (2 Replies)
Discussion started by: chandana hs
2 Replies

2. UNIX for Dummies Questions & Answers

Ctrl-V + Ctrl-J for newline character does not work inside vi editor

Hi friends, I am trying to add a newline char ('\n') between the query and the commit statement in the following shell script. #! /bin/sh echo "select * from tab; commit;" > data.sql I have tried typing in "Ctrl-V + Ctrl-J" combination which has inserted ^@ (NUL) character but the commit... (1 Reply)
Discussion started by: royalibrahim
1 Replies

3. Shell Programming and Scripting

ctrl-c in shell script

The below script has Perl script in it where it gives the usage details. filer.sh echo echo -en "Enter filer : " read filer echo "test.pl -f $filer -F L" Output ========= The following hosts are online and available: Name Total Allocated Used ... (2 Replies)
Discussion started by: nareshkumar522
2 Replies

4. Shell Programming and Scripting

How to handle CTRL+Z or CTRL+C in shells script?

Hi, while executing shell script, in the middle of the process, if we kill the shell script( ctrl+z or ctrl+c), script will be killed and the files which using for the script will be in the folder. How to handle those scenarios. Is there any possibilities, if user breaks the script, I need to... (3 Replies)
Discussion started by: ckchelladurai
3 Replies

5. Shell Programming and Scripting

ctrl-c in script

how to send ctrl-c signal in scripts ??? i am executing top command in .exp script top command gives cpu running activities on your machine eg # top top - 18:41:01 up 8:38, 5 users, load average: 0.03, 0.16, 0.16 Tasks: 172 total, 1 running, 170 sleeping, 0 stopped, 1 zombie... (3 Replies)
Discussion started by: alexzander18
3 Replies

6. Shell Programming and Scripting

Ctrl-C or Ctrl-Z causing exit the session

H! I have written script where it need to invoke the perl script in background, then write the pid in temp file then bring back the job to foreground. whenever the Ctrl-C or Ctrl-Z is pressed in the script has to exit and prompt should be dispalyed. but this script causing exit from shell session... (2 Replies)
Discussion started by: jramesh1
2 Replies

7. Shell Programming and Scripting

Adding CTRL-M Character

Hi, I have file generated in HP-UNIX environment (for Example) with the line feed (i.e $): a$ b$ C$ Now, I need to append CTRL-M character at the end of each line, but the last line of the file should not have both CTRL-M and Line Feed (i.e ^M and $). The file should look like: a^M$ b^M$... (2 Replies)
Discussion started by: mohan.nadaraja
2 Replies

8. AIX

Disable ctrl-c,ctrl-d,ctrl-d in ksh script

I wrote a ksh script for Helpdesk. I need to know how to disable ctrl-c,ctrl-z,ctrl-d..... so that helpdesk would not be able to get to system prompt :confused: (6 Replies)
Discussion started by: wtofu
6 Replies

9. UNIX for Dummies Questions & Answers

Script ctrl+c

How do you make a script so the user can not press ctrl+c and break out of the script? Thanks, :) (1 Reply)
Discussion started by: newtounix
1 Replies
Login or Register to Ask a Question