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 ideas?

rsh host "cd a/b
exe<< stop
1
2
stop
exe2<<stop2
a
b
stop2
foreach ptcluster (30 35 40 45 50)
echo PTCLUS=$ptcluster
end
"

I have read read the following statement, but I don't know if it is the real issue:
"When this command is read from the terminal, the loop is read once prompting with `foreach? ' (or prompt2) before any statements in the loop are executed. If you make a mistake typing in a loop at the terminal you can rub it out."

It's always good to try searches before asking. This was discussed a few days ago. Check here.

Cheers,

Keith

hi, thank you for the suggestion, but the thread you have pointed out is quite different from my issue:
I want to perform a loop inside the compound command. in any case I have tried the suggestion, but didn't worked.
Cheers Michele

For one thing, try this:
$ xyz=hello
$ echo "xyz = $xyz"
xyz = hello
$
Shells look inside double quoted strings and replace variables. Your variable $ptscluster will be replaced before your local shell even locates the rsh command. This doesn't explain why you're not looping, but I'm not a csh expert. You should put scripts in an executable file, not in an argument to a command line. Once you use something like "rsh host ./remoteloop", all of the problems will vanish. Make sure you have a line like "#! /usr/bin/csh" in your remoteloop file. Note that you can create remoteloop locally, rcp it into place, chmod it, run it, and then remove it.

I have tried this workaround (even if I see it as a defiance :slight_smile: ).
but another problem arised: i want to keep the control in the main script of the variable to be passed so I would like to pass them to the script.
this is the "inner" script:
#!/bin/sh
# loop through a set of numbers
# echo $pt
echo nome$1
echo pt$2
echo eta$3
for i in 1 2 ;
do ../herlib/hwuser<<stop ;
$1
$2 $3
$i
stop

done
when I do
$ ./forloop a b c
it works but when it is called by another script it fails to recognize the variables.
for example: I call the previous script (forloop) through
name=tt_25_5_0jet
pt=20
eta=0.6
./forloop<<stop
$name
$pt
$eta
stop
but don't work... any idea?
THANKS in advance Michele

Use -n with rsh command & then you'r probelem will surely get solve.

EG: rsh host -n "cd a/b

Regards,
Lahiru Jeewantha