rsh and for loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting rsh and for loop
# 1  
Old 09-15-2005
rsh and for loop

hi
I wanted to use the for loop structure in tandem with rsh command and the result to be redirected into a local .lst file within a shell script .
Tried the following but does not help Smilie .

rsh ABCD "cd /bosp/local/home/linus/;for i in `ls -ltr | grep ^- | awk {'print $9'}`
do
echo service:`pwd` /`sum $i | awk {'print $3 ":" $1'}``ls -ltr $i | awk {'print ":"$1'}`
done">>/bosp/local/home/linus/result/cde.lst;



Thanx in advance
newbee2005
# 2  
Old 09-15-2005
That super complex compound command is delimited by double quotes. But it also has double quotes internally. That is not gonna work.
# 3  
Old 09-16-2005
Thanx
u are rite, i had to seperate the commands as
-those in the For condition
-those inside the do loop
by seperate sets of double quotes ...
but another issue that i didnt face before is that
the commands within the do loop again have to be individually seperatd by semi colons , but that causes the result to be displayed on seperate lines , whereas i want the result of one loop to be on the same line ,
can anyone help with that ...

"echo service:`pwd` /;"sum $i | awk {'print $3 ":" $1'}";"ls -ltr $i | awk {'print ":"$1'}""


newbee2005
# 4  
Old 09-16-2005
You should make your complex compound command into a shell script. And then just run that script.
# 5  
Old 09-16-2005
This piece of command is actually a shell script .
There is a second shell script which depends on this script .
I was trying to eliminate the need for having 2 different scripts by including one in the other thats when the problem ....

so having this as a script is not possible
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rsh reboot in a loop?

Hi folks. I'm trying to get the following script working for rebooting a bunch of clients. Up to now I've been using PSSH, but when they all startup again at the same time I get a few mount problems. So, I'm trying to stagger the reboot command. I know reboot will depend on what's running at... (3 Replies)
Discussion started by: MuntyScrunt
3 Replies

2. Shell Programming and Scripting

awk, double variable, for loop and rsh

Hello folks, I've a (perhaps) simple question. In a text file I've : server_name1: directory1 server_name2: directory2 server_name3: directory3 I want to make a loop that lets me connect and operate on every server: rsh server_name1 "ls -l directory1" I've tried with awk,... (6 Replies)
Discussion started by: gogol_bordello
6 Replies

3. Shell Programming and Scripting

rsh script with inside a for loop

hi everyone, I have the following problem: the foreach loop inside rsh doesn'work. I have tried the for command but it's not recognized. with the foreach command I don't receive any error, but it doesn't really make the cycle, ignoring the foreach and executing 1 time the echo command. Anyone has... (5 Replies)
Discussion started by: trekianov
5 Replies

4. Shell Programming and Scripting

rsh breaking me out of loop

Hey all I have two scripts, one script containing the guts of my code. The other simply loops through a list, calling the other script on each iteration. Problem is when I add the line `/usr/bin/rsh -l root $HOSTNAME ""` to my main script, the loop never seems to exectute any more... (1 Reply)
Discussion started by: mark007
1 Replies

5. UNIX for Advanced & Expert Users

Rsh

Hi All, I want to execute a command from my Windows machine to Linux machine using RSH only d:> rsh <Linux machine add> -l <user_name> pwd>dir in linux machine users home directory in .rhosts file I entered the windows machine IP address and user name. In linux etc/hosts.equiv file I... (1 Reply)
Discussion started by: sarwan
1 Replies

6. Linux

Help in RSH

Hi All, I want to execute a command from my Windows machine to Linux machine. d:> rsh <Linux machine add> -l <user_name> pwd>dir in linux machine users home directory in .rhosts file I entered the windows machine IP address and user name. In linux etc/hosts.equiv file I entered the... (1 Reply)
Discussion started by: sarwan
1 Replies

7. Shell Programming and Scripting

Help on rsh

Hi, i need to xecute rsh or rexec command in order to execute the script on multiple server. The problem i am facing is when i execute rsh command with login name and hostname it ask me password interactively can some body help me how i can pass password along with the command or how to... (1 Reply)
Discussion started by: deep022in
1 Replies

8. UNIX for Advanced & Expert Users

While read loop and rsh

Hi all I have a while read loop that I use to process a file line by line. The reason I am using this is due the fact that I have spaces in the line and a for loop treats the space as a delimeter for the next record. In this while loop I have a rsh. It appears that cos of the rsh, I never get... (1 Reply)
Discussion started by: 104234
1 Replies

9. UNIX for Advanced & Expert Users

where is rsh

Hi, when a user use rsh command (or any other) , where is the executable used by him ? Many thanks in advance. (1 Reply)
Discussion started by: big123456
1 Replies

10. Shell Programming and Scripting

rsh command in a while loop

Hi , reading a "file1" with 2 data in each line (VAR1 and VAR2) , i'm using a while loop like this : cat file1|awk '{print $1,$2}'|while read VAR1 VA2 do echo $VAR1 echo $VAR2 done as this example shows , it works but if between do and done i use a "rsh" command , the script reads... (6 Replies)
Discussion started by: Nicol
6 Replies
Login or Register to Ask a Question