set variables on remote system

Hi,

I try to run a script on remote systems with ssh

it should execute a command, read values from stdout, use it as input for a loop
and works with this variable on remote system

but the variable isn't working, I guess because export, echo , or the loop itself are shell builtins and not a binary/script on the remote system

how can I get something like this to work:

ssh hostname "a=5 ; echo $a"

the variable should be set in a new process environment on the remote system, not on local system

or

ssh hostname "for i in $(command1); do command2 $i; done"

thanks in advance

funksen

I suggest you pipe the commands as stdin.

Also it's worth checking what shell the sshd session will actually be running for you.

ssh user@host <<EOF
echo \$0
echo \$SHELL
ps -p \$\$
EOF

works great, thanks