|
|
| "be consistent" | |
| PerlMonks |
Net::OpenSSH changing directory does not work properlyby Pascal2020 (Initiate) |
| on Dec 07, 2011 at 09:35 UTC ( #942191=perlquestion: print w/ replies, xml ) | Need Help?? |
|
Pascal2020 has asked for the
wisdom of the Perl Monks concerning the following question:
Hi I want to use Net::OpenSSH to make life a bit easier in maintaining systems. For this I want to first copy a file to the destination machine and afterwards login to the machine, untar the file to a temp directory and changing the directory to this temporary directory so I can run a script from that directory. However this fails to work. If I do for instance 'cd /usr/local/ ; ls -la' as system command it works fine. If I first do 'cd /usr/local/' and then a new command 'ls -la' it gives the listing of the login directory. Ergo it does change the directory but it loses the working directory when the next system command is run. Example code
Output: Output cmd1: total 96 drwxr-xr-x 12 root root 4096 Dec 6 21:00 . drwxr-xr-x 15 root root 4096 Dec 6 21:01 .. drwxr-xr-x 2 root root 4096 Oct 1 2009 bin drwxr-xr-x 2 root root 4096 Oct 1 2009 etc drwxr-xr-x 2 root root 4096 Oct 1 2009 games drwxr-xr-x 2 root root 4096 Oct 1 2009 include drwxr-xr-x 2 root root 4096 Oct 1 2009 lib drwxr-xr-x 2 root root 4096 Oct 1 2009 lib64 drwxr-xr-x 2 root root 4096 Oct 1 2009 libexec drwxr-xr-x 2 root root 4096 Oct 1 2009 sbin drwxr-xr-x 4 root root 4096 Dec 6 21:00 share drwxr-xr-x 3 root root 4096 Dec 6 20:10 src Output cmd2: total 160 drwxr-x--- 7 root root 4096 Dec 7 10:02 . drwxr-xr-x 25 root root 4096 Dec 7 09:23 .. -rw------- 1 root root 1270 Dec 6 21:06 anaconda-ks.cfg -rw------- 1 root root 198 Dec 6 20:11 .bash_history -rw-r--r-- 1 root root 24 Jul 13 2006 .bash_logout -rw-r--r-- 1 root root 191 Jul 13 2006 .bash_profile -rw-r--r-- 1 root root 176 Jul 13 2006 .bashrc drwxr-xr-x 4 root root 4096 Dec 7 10:02 .cpan -rw-r--r-- 1 root root 100 Jul 13 2006 .cshrc -rw-r--r-- 1 root root 36832 Dec 6 21:06 install.log -rw-r--r-- 1 root root 3686 Dec 6 21:06 install.log.syslog drwx------ 2 root root 4096 Dec 7 10:02 .libnet-openssh-perl drwx------ 2 root root 4096 Dec 7 10:02 .ssh -rw-r--r-- 1 root root 129 Jul 13 2006 .tcshrc Tested on CentOS 5.7 and RedHat 5.6. Also compiled a new version of OpenSSH on the main and destination machine but unfortunatly the results stay the same. Can someone tell me what I am doing wrong? Do I need an extra setting or use a different command?
Back to
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||||||