[Ssh-sftp-perl-users] $PATH setup for SSH2->cmd, using NET::SSH::PERL
Brought to you by:
dbrobins
From: Amit J. <ami...@ya...> - 2008-03-14 01:30:01
|
I am having problems executing CLI cmds once I login to a device because the PATHS are not set properly in the opened session. When I use the login() & cmd() functions the PATH is very different than when I use the shell() fuction (or use another SSH client to login). Code: #!/usr/bin/perl use warnings; use strict; use Net::SSH::Perl; use Math::BigInt::GMP; my $ssh = Net::SSH::Perl->new($ip,(protocol=>'2,1',port=>'22',debug=>'true')); my $ssh = login("a.b.c.d","username","password"); my ($out, $err, $exit) = $ssh->cmd("echo \$PATH"); print $out; $ssh->shell(); Here's the relevant output: Got channel open confirmation, requesting shell. Requesting service shell on channel 0. channel 1: new [client-session] Requesting channel_open for channel 1. Entering interactive session. Sending command: echo $PATH Requesting service exec on channel 1. channel 1: open confirm rwindow 0 rmax 32768 input_channel_request: rtype exit-status reply 0 channel 1: rcvd eof channel 1: output open -> drain channel 1: rcvd close channel 1: input open -> closed channel 1: close_read channel 1: obuf empty channel 1: output drain -> closed channel 1: close_write channel 1: send close channel 1: full closed /usr/bin:/bin:/usr/sbin:/sbin -------> $PATH when using login & cmd functions channel 3: new [client-session] Requesting channel_open for channel 3. Entering interactive session. Requesting service pty-req on channel 3. Requesting shell. Requesting service shell on channel 3. channel 3: open confirm rwindow 0 rmax 32768 LFab142_5000:admin> echo $PATH echo $PATH /fabos/link_abin:/fabos/link_sbin:/fabos/link_bin -------->> $PATH is different when using $ssh->shell() method The CLI cmds are located under /fabos/link_abin which translates to /fabos/bin. How to setup the defualt paths ? |