Strange behaviour of ssh
Philipp Marek
philipp.marek at linbit.com
Mon Nov 7 23:28:38 EST 2011
Hello Lukas!
On Monday 07 November 2011, Lukas Razik wrote:
> I've Debian 6.0.3 with OpenSSH_5.5p1 and problem with the execution of
> remote commands via ssh.
...
> Here normally I should get the version information of mpirun twice but
> the first one fails: $ ssh cluster2 mpirun --version ; mpirun --version
> bash: mpirun: command not found
> mpirun (Open MPI) 1.4.3
>
> Here I should get the place of "mpirun" twice but the first "which"
> doesn't find an "mpirun" and prints nothing: $ ssh cluster2 which mpirun
> ; which mpirun
> /usr/mpi/gcc/openmpi-1.4.3/bin/mpirun
>
> The echo command prints the right "$PATH":
> $ ssh cluster2 echo "$PATH"
> /usr/mpi/gcc/openmpi-1.4.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/ga
> mes:/usr/games
>
> So, does anyone of you have an idea what there could be wrong?
yes. The ";" is parsed by the _local_ shell, ssh only transmits the first
part to the remote host - the rest is run locally.
And "$PATH" is expanded locally, too - try with '$PATH'.
To run multiple commands remotely you could try
ssh cluster2 /bin/sh -c 'mpirun ; mpirun ; which mpirun; echo $PATH'
Regards,
Phil
More information about the openssh-unix-dev
mailing list