![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| script : How many sessions are there ? | xaviraan | Shell Programming and Scripting | 3 | 06-11-2009 08:33 AM |
| SSH sessions from bash script | tsurko | Shell Programming and Scripting | 3 | 04-14-2009 04:40 PM |
| how to make your bash script run on a machine with csh and bash | npatwardhan | Shell Programming and Scripting | 3 | 11-19-2008 04:17 AM |
| passing variable from bash to perl from bash script | arsidh | Shell Programming and Scripting | 10 | 06-04-2008 12:25 PM |
| Why generate "ash and bash" different output for same bash script? | s. murat | Shell Programming and Scripting | 0 | 05-26-2008 07:19 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
SSH sessions from bash script
Hi Forum.
First of all thanks for reading. I need some help here. I have been checking some other posts about this issue, but I still have problems... I'm trying to conect througn ssh to several machines to kill some process and I have problems with the " ' ' ". This is what I'm trying to do: ssh -o "StrictHostKeyChecking no" $IP_START ps -ef | grep $USER | awk '{print "kill -9 "$2""}' | sh I know for sure that this works: ps -ef | grep $USER | grep | awk '{print "kill -9 "$2""}' | sh And I know that the way to do multiple commands in ssh is: ssh user@server 'command1; command2; command3' or ssh user@server "command1; command2; command3" So with this, I have tried all the possible combinations: ssh -o "StrictHostKeyChecking no" $IP_START "ps -ef | grep $USER | awk '{print \"kill -9 \"$2\"\"}' | sh" ssh -o "StrictHostKeyChecking no" $IP_START 'ps -ef | grep $USER | awk \'{print "kill -9 "$2""}\' | sh' .... But this command is killing me: awk '{print "kill -9 "$2""}' Could any body help me? Thanks in advance... |
|
||||
|
Thank you very much Tony!!!
It worked!!! ![]() ![]() ![]() ![]() It makes sence to put a scape character also to the $!! |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|