Loop in remote shell command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Loop in remote shell command
# 1  
Old 08-08-2005
Loop in remote shell command

Hi All

Does anyone have any idea on how I can create a loop when running a remote shell. e.g.
If I want to execute the following command remotely and log the output locally
for x in `lsvg`
do
lsvg $x
done > /tmp/myfile

I have tried
rsh myhost -l root for x in `lsvg`^Jdo^Jlsvg $x^Jdone
however get the error
ksh: 0403-057 Syntax error at line 1 : `for' is not matched.

Any ideas.

Thx

J
# 2  
Old 08-08-2005
Try this :


Code:
rsh myhost -l root 'lsvg|xargs lsvg'


Jean-Pierre.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get the for loop output from a remote server in UNIX shell scripting?

Hi, I am using ksh , when i try to use for loop i am getting the expected output. $for variable in $(ps -fu user | grep -i something/ | grep -i something | grep -v grep | awk '{print $2}');do > grep $variable /tmp/some_path/*/* > done when tried the below to remote server, getting... (4 Replies)
Discussion started by: karthikram
4 Replies

2. Shell Programming and Scripting

If else condition inside for loop of awk command in UNIX shell scripting

Hi , Please excuse me for opening a new thread i am unable to find out the syntax error in my if else condition inside for loop in awk command , my actual aim is to print formatted html td tag when if condition (True) having string as "failed", could anyone please advise what is the right... (2 Replies)
Discussion started by: karthikram
2 Replies

3. Shell Programming and Scripting

Until string from remote command equals value run remote command

I solved my issue by using the following code #!/bin/bash function GET_STATUS { #values Active Passive Failed ssh -a localhost '/home/user/fakecommand.sh' } STATE="unknown" until ] do echo $STATE sleep 5 STATUS=`GET_STATUS` echo $STATUS | grep Active &&... (1 Reply)
Discussion started by: $scipt_Kid
1 Replies

4. Shell Programming and Scripting

while loop stops after first iteration - remote ssh exit command problem?

I have written the following script to update some Debian boxes. #!/bin/bash mxg_hosts_file="/etc/mxg/ssh-hosts" while read line ; do mxg_host="$(echo ${line} | awk -F":" '{print $1}')" mxg_port="$(echo ${line} | awk -F":" '{print $2}')" echo "Connecting and Upgrading... (3 Replies)
Discussion started by: jelloir
3 Replies

5. Shell Programming and Scripting

How do I run a shell command in a while loop?

The command is: sic -h irc.freenode.net 2>&1 | tee -a irc.log Where sic is an IRC client, and I'm piping the output to tee in order to log my IRC sessions. I'm trying to handle reconnects by running it in a while loop in the shell process and cat the initial commands into sic's stdin. I... (1 Reply)
Discussion started by: guitarscn
1 Replies

6. Shell Programming and Scripting

executing command in a remote machine through ssh - shell script

Hi All, i have two machines like x and y . my requirement is i should connect to machine Y from x through ssh connection . and do some operation such as copy and move and delete files in Y machine . i tried with this code but it is doing in machine x only . and i need to exit from Y when... (1 Reply)
Discussion started by: rateeshkumar
1 Replies

7. Shell Programming and Scripting

Setting Variables WITHIN For Loop in DOS Command Shell

I'm wondering if any of you could lend an assist with a small problem. First, I'm under the impression I need to use Delayed Environment Variable Expansion (DEVE), based on other things I've read across the web. Summary: trying to use command shell (cmd.exe) in XP sp3 (if that's relevant) to... (4 Replies)
Discussion started by: ProGrammar
4 Replies

8. Shell Programming and Scripting

C Shell - Command Inside a Loop

I have a command nested in some while loops to parse some data that looks something like this. while ($condition) while ($condition) ... gzcat /dir/$fileName.gz | grep $searchString > out_file end end On the first loop, the command is executed properly (and takes maybe 10... (3 Replies)
Discussion started by: hobbers
3 Replies

9. Shell Programming and Scripting

command not working with rsh(remote shell)

Hi, root@air01a>SS7Manager -status This command gives correct output. But when I write this in script and run it on SUNMC (which can connect to air01 and by default login as root). It gives the error "SS7manager not found" or "can not open". Here is the scripts. #!/bin/sh rsh air01a... (4 Replies)
Discussion started by: lastkey
4 Replies

10. UNIX for Dummies Questions & Answers

remote shell command

1. is there anyone know what is the record format for file .rhosts ? 2. where to put .rhosts file ? is it on caller or on callee ? 3. will remsh command works if callee is not unix platform (say AS400) ? 4. best regards, Yatno (4 Replies)
Discussion started by: yatno
4 Replies
Login or Register to Ask a Question