in reply to Re^2: Net::OpenSSH can't change working directory
in thread Net::OpenSSH can't change working directory

Tried your code and it worked. I used 'cd /usr/local/bin; ls' and got the expected listing

You haven't said if you tried 'cd /' or something else like 'ls' as commands. Did that work or not?

The FAQ of Net::OpenSSH informs us that the module uses ssh in command mode, i.e. it logs in for each new command string. Using Expect together with Net::OpenSSH or other ssh modules is offered as a solution, it should use interactive mode.

You could also just join commands together with ';', for example "cd /usr/local/bin; ls; mv $somefile $otherfile". Low-tech but simple.

  • Comment on Re^3: Net::OpenSSH can't change working directory

Replies are listed 'Best First'.
Re^4: Net::OpenSSH can't change working directory
by josh803316 (Beadle) on Jul 17, 2010 at 16:45 UTC
    Thanks for the advice and yes I agree, my local script works as well and I noticed that if I separate the command strings they run independently just as you suggested. The solution will be for me to join the commands into a complete set and then figure out a way to group the results. Thank you again for the suggestions and advice.