franc1967 has asked for the wisdom of the Perl Monks concerning the following question:

Dear all,
i'm using net:ssh::perl and net::sftp with cygwin and windows XP SP2. Everything is working fine, even the public/private key authentification.

But i'm not able to execute a command like "ifconfig". I get a message that the bash doesn't know the command. Commands like "ls" or "who" can be processed successfully.

What can be the reason for this?

(with $ssh->shell, openssh or local access i can execute this command)

Thanks in advance for your response.

A small code:

use Net::SSH::Perl; $user1 = "xxxx"; $host = "aa.bbb.ccc.dd"; my @files = ("$ENV{HOME}/.ssh/tsg"); my $ssh = Net::SSH::Perl->new($host, protocol => 2, cipher => "3des-cb +c", port => 22, identity_files => \@files); $ssh->login($user1); my ($err, $out) = $ssh->cmd("ifconfig"); my @array_daten = split(/\n/,$out); foreach (@array_daten) {print "$_\n"}; my ($out) = $ssh->cmd("who"); my @array_daten = split(/\n/,$out); foreach (@array_daten) {print "$_\n"};

20070727 Janitored by Corion: Killed PRE tags, added formatting, code tags, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: net::ssh::perl will not execute every command
by Fletch (Bishop) on Jul 27, 2007 at 21:29 UTC

    ifconfig in particular is usually in /usr/sbin or /sbin and that directory's not going to be in the vanilla PATH for normal users. Most likely is that your PATH is altered by a shell startup file (say .bash_profile) which isn't being sourced by the shell that you're getting when you connect this way. You'd probably get similar results if you tried to run the command via "ssh otherhost ifconfig -a". Check the bash manual page for the exact set of startup files it sources under different circumstances.