Needing guidance, running xargs on remote machine


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Needing guidance, running xargs on remote machine
# 1  
Old 06-16-2011
Needing guidance, running xargs on remote machine

I am trying to run the follow command. I am running this from a korn shell script.

Code:
rsh foobar ps -fu dram | grep sshd: | grep -v grep | awk '{print $2}' | xargs -I xx kill xx

I get the PID back excluding the xargs part but after adding on the xargs part it fails to locate the PID and is probably trying to kill it locally. I am sure there are some stuff you can put around the command to make it carry through to the remote server but I could guess all night and probably not get it. Any assistance would be appreciated.

Thanks.
# 2  
Old 06-16-2011
You could probably put quotes around the whole thing:

Code:
rsh ... "ps .... | xargs ..."

# 3  
Old 06-16-2011
Well I tried that....gets me closer but still missing something.

Code:
root@flipper:/ $ rsh foobar "ps -fu dram | grep sshd: | grep -v grep | awk '{print $2}' | xargs -I xx kill xx"
Usage: kill [ -SignalNumber|-SignalName|-s [SignalName|SignalNumber]] {ProcessID}...
Usage: kill -l [exit_status]

Did the same thing trying to list out a file that only existed on the remote machine and it's like it don't see value of the trailing "yy" variable (Sorry I don't know the official term for that value.) but sort of does as well since it list the file (or part of the name /tmp) but gets the "xx does not exists error".

Code:
root@flipper:/ $ rsh flipper "ls -al /tmp | grep xx | grep -v grep | awk '{print $9}' | xargs -I yy ls -al /tmp/yy"
ls: 0653-341 The file /tmp/-rw-r--r--    1 root     system            0 Jun 16 17:57 xx does not exist.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Keep a script on remote machine running (nohup?)

Hi, I'm using expect to ssh into remote machine (i know its not the best practice), and run script "script.sh". This "script.sh" checks whether an other process (some another script) is running and if not, it runs it as some other user. #!/bin/bash /usr/bin/expect << EOD set... (5 Replies)
Discussion started by: oseri
5 Replies

2. Red Hat

iptables applied in local machine, can't ssh remote machine after chain changed to DROP

I want to SSH to 192.168.1.15 Server from my machine, my ip was 192.168.1.99 Source Destination was UP, with IP 192.168.1.15. This is LAN Network there are 30 Machine's Connected to the network and working fine, I'm Playing around the local machine's because I need to apply the same rules in... (2 Replies)
Discussion started by: babinlonston
2 Replies

3. OS X (Apple)

Quit a shell script thats running on a remote machine

I'm in a situation where I am executing a shell script(Bash) on another machine remotely using ssh, and for various reasons sometimes need to quit it and restart it. The shell script being run does many different things, so its hard to know what process to kill on the remote machine, and even if I... (2 Replies)
Discussion started by: TheDrizzle
2 Replies

4. Shell Programming and Scripting

Running remote system shell script and c binary file from windows machine using java

Hi, I have an shell script program in a remote linux machine which will do some specific monitoring functionality. Also, have some C executables in that machine. From a windows machine, I want to run the shell script program (If possible using java). I tried with SSH for this. but, in... (1 Reply)
Discussion started by: ram.sj
1 Replies

5. Shell Programming and Scripting

check web server running on local and on remote machine

Hi , How to check whether web server is running from remote machine How to check whether web server is running on web server itself Can any one help me soon (1 Reply)
Discussion started by: satheeshkr_cse
1 Replies

6. UNIX for Advanced & Expert Users

Script running on remote machine - How ??

Hi All, This was an interview question " There is a clean-up shell-script in one UNIX machine and it is connected to 100 other UNIX machines. Howe can we run the script on all the 100 machines without ftping/copying the script to target machines ? I was unable to answer, please answer if... (5 Replies)
Discussion started by: coolbhai
5 Replies

7. Red Hat

To find the LATEST file from a dir on REMOTE machine and SCP to local machine?

Hi All, URGENT - Please help me form a scipt for this: I need the LATEST file from a dir on REMOTE machine to be SCP'd to a dir on local machine. (and I need to execute this from local server) I know that the below cmd is used to find the LATEST file from a dir. But this command is not... (3 Replies)
Discussion started by: me_ub
3 Replies

8. Shell Programming and Scripting

running script in background on remote machine

Hi there I have a script which is running a remote command on hundreds of boxes, it takes around 5 minutes to return an output from this command and because i am running this all from a central box, it goes off to each box in my for loop sequentially meaning that my script will wait for output... (5 Replies)
Discussion started by: hcclnoodles
5 Replies

9. UNIX for Advanced & Expert Users

Running script on remote machine

if i have a script in my system which i need to run on remote system using ssh, how shall i do it? One easy way to to first scp it to remote machine and then run it on remote machine using ssh. Is there any one step way to do it. Preferably one in which i should give password only once (3 Replies)
Discussion started by: vickylife
3 Replies

10. UNIX for Dummies Questions & Answers

leave a process running in a remote machine

Hi, I would like to run a process in my gentoo machine from a consolte (putty) in Windows and would like that this process keep on going when I close the console in Windows (i.e closing this session). The process should take a long time and I do not want to leave the Windows machine running... (3 Replies)
Discussion started by: pbasil
3 Replies
Login or Register to Ask a Question