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

Hi Monks,
As you have helped me so well in the past, I come back for more advice.
I am currently writing a script to connect to an Alteon (a load balancer) using Net::SSH::Perl. The Alteon has a Command line interface which can be accessed through and SSH connection. I am using the following code with mixed results.
my (%args) = @_; $args {hostname} = "XX.XXX.XXX.XXX"; $args {dm_user} = "username"; $args {password} = "password"; $args {protocol} = "2,1"; $args {debug} = "1"; my $ssh = Net::SSH::Perl->new($args {hostname}, %args); $ssh -> login($args {dm_user}, $args {password}); $ssh -> shell;
This code will connect and give me the prompt I would see when logging in normally.
If I use the same connection, but try to pass a command like so
# my ($stdout, $stderr, $exit) = $test_hash {ssh_session} -> cmd ($cmd +);
The connection is closed with the following message
Received disconnect message: Switch: SCP command not recognized. at /usr/lib/perl5/site_perl/5.8.0/Net/SSH/Perl/SSH1.pm line 369
Has anyone any ideas that may help me. I am open to all ideas :-)

Replies are listed 'Best First'.
Re: Alteon's and SSH
by castaway (Parson) on Nov 05, 2003 at 14:24 UTC
    Which command are you actually passing it? It looks to me like you're trying to 'scp' a file, and Net::SSH::Perl doesnt recognise the command, or that the machine doesn't (doesn't support scp, or the 'scp' command isnt in the PATH for some reason..)

    C.

      And example of the content of $cmd is
      $cmd = "/info/dump"
      which when executed on the command line of the Alteon gives a screen dump of the current configuration. The message about SCP command message appears whenever I use the $ssh->cmd function (regardless of what command is written).
      An interesting thing about this is that if you try and scp command from a shell to the Alteon, the same message is recieved.
Re: Alteon's and SSH
by iburrell (Chaplain) on Nov 05, 2003 at 18:32 UTC
    Can you execute commands with the ssh program?
    ssh host foo
    My suspicion is that the Alteon does not allow executing commands with ssh. 'scp' is the most common program executed through ssh which is where error message comes from. It sounds like it provides a command prompt where commands can be entered. But getting a shell is different from running a program.
Re: Alteon's and SSH
by simonm (Vicar) on Nov 06, 2003 at 05:44 UTC
    I've run into this same issue with remote access to an Alteon load balancer.

    In short, I don't you can't use the $ssh->cmd() method for this connection.

    I think that you can do this within the $ssh->shell() method by first setting up a call to $ssh->register_handler() which is prepared to listen for input and send responses using $channel->send_data()... But I wasn't able to find any good examples of this in the documentation. (Here's a bad example.)

      Thanks for the replies. I tried the method sugested of the ssh command. When I do that, I get the following error on the command line
      Received disconnect from XX.XXX.XXX.XX: Switch: SSH protocol error - packet type not expected.

      I have not had chance to try the shell method with Net::SSH::Perl yet but I shall get onto that and post back with how I go.
      Thanks for the help so far