in reply to Calling a remote ssh connection from perl

Perl's system() may or may not invoke a shell. If it does, then it may not be the usual shell you get when you login (e.g. bash, sh, csh), or it may be that, but it may not be interactive and so it may be missing some crucial initialisation you otherwise get when running ssh at the command line.

If it doesn't call a shell, it will do an execvp which inherits the environment BUT it will not do the initialisations, conditional initialisations, it will not call other scripts etc. like one gets when opening a prompt and a new interactive shell.

If it does call a shell, it may not be the one you are normally using (sh vs bash) and so it will be doing initialisations which are not specific to your setting. Even if you explicitly specify which shell to use, it will not be "interactive" unless you specify so explicitly as well. That's important because many shell init scripts distinguish between interactive and non-interactive invocations. This further complicates things because a lot of functionality in these init scripts is conditional on interactivity.

If there is only one scalar argument, the argument is checked for shell metacharacters, and if there are any, the entire argument is passed to the system's command shell for parsing (this is "/bin/sh -c" on Unix platforms, but varies on other platforms). If there are no shell metacharacters in the argument, it is split into words and passed directly to "execvp", which is more efficient.

The bottomline is: read the manual and then choose the execution mode which exactly matches your requirement and be explicit on what you want, do not rely on Perl's defaults.

This will run your ssh command in an interactive (-i), bash shell, assuming this is the one you get when you login and open a prompt: system('/bin/bash', '-i', '-c', 'ssh root@remoteIP /usr/bin/ls'); . Whether that will do what you want is doubtful as there are other factors in your environment which I am not aware of.

bw, bliako