could not send commands SSH session with Net::SSH::Expect


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting could not send commands SSH session with Net::SSH::Expect
# 1  
Old 08-28-2009
could not send commands SSH session with Net::SSH::Expect

I am using Net::SSH::Expect to connect to the device(iLO) with SSH. After the $ssh->login() I'm able to view the prompt, but not able to send any coommands.

With the putty I can connect to the device and execute the commands without any issues.

Here is the sample script

my $ssh = Net::SSH::Expect->new (
'host' => $host,
'user' => $login,
'password' => $passwd,
'timeout' => 15,
'raw_pty' => 1,
'log_file' => "iloExpect.log",
);
if(!defined($connect=$ssh->login()))
{
print "Login Failed with the Host = $host Login $login and Password $passwd";
}
if($connect !~ /$prompt/i)
{
print "\nCould not get the prompt \n";
exit(1);
}
print "\nSending the command [$cmd]\n";
my $output = $ssh->exec('help');
print "\nOutput [$output]\n";



Thanks in Advance,
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Ssh = ssh expect and keep everything not change include parameter postion

I have write a script which contains ssh -p 12345 dcplatform@10.125.42.50 ssh 127.0.0.1 -p 5555 "$CMD" ssh root@$GUEST_IP "$CMD" before I use public key, it works well, now I want to change to "expect", BUT I don't want to change above code and "parameter position" I can post a... (1 Reply)
Discussion started by: yanglei_fage
1 Replies

2. Shell Programming and Scripting

set Net:SSH:Expect timeout and set it again.

SSHing into a machine can take a few seconds, but after I'm in, the commands return quickly. I was wondering if the timeout setting can be changed once I'm logged into the machine. Does anyone know if this can be set on the fly? The problem here is, if I have to set timeout = 10, it'll take 10... (1 Reply)
Discussion started by: mrwatkin
1 Replies

3. UNIX for Dummies Questions & Answers

SSH session

I ran a job using SSH and then used screen command followed by space bar. Then I ran the job. But after some hours, the internet connection was lost.This had happened to me before. I used to run the whole job again. Today I came across the fact that I could restart the jobs without having to do it... (2 Replies)
Discussion started by: nellierd
2 Replies

4. Shell Programming and Scripting

Send Remote Commands via SSH with variables

Hi there I found the Command to send commands to other servers like: sv01> ssh user@sv02 'ps -ef' But I cant use Variables from a script i want to execute on another server like: sv01> ssh user@sv02 'cd $SCRIPTHOME' although the variable is set on sv01. How can I run commands on sv02 with... (2 Replies)
Discussion started by: DarkSwiss
2 Replies

5. Shell Programming and Scripting

Bash commands to an 'ssh' within an ssh'

I've struggled to find a solution to this problem from searching so I thought I'd write a post to see what can be done. I'm attempting to connect and run commands on 'server2' but because of security limitations I cannot access it directly. I can however ssh into 'server1' and then into... (7 Replies)
Discussion started by: mcintosh.jamie
7 Replies

6. HP-UX

ssh session getting hung (smilar to hpux telnet session is getting hung after about 15 minutes)

Our network administrators implemented some sort of check to kill idle sessions and now burden is on us to run some sort of keep alive. Client based keep alive doesn't do a very good job. I have same issue with ssh. Does solution 2 provided above apply for ssh sessions also? (1 Reply)
Discussion started by: yoda9691
1 Replies

7. Shell Programming and Scripting

Expect, SSH and multiple passed commands

Hey Everyone, I have found this script online that has almost all the features I am looking for. However, I do not know enough expect to debug the problem. http://linuxgazette.net/100/misc/tips/sshtool.expect.txt First, it Traps out after it collects the user's password. I do not know... (0 Replies)
Discussion started by: patchsmyle
0 Replies

8. Shell Programming and Scripting

Make ssh and send commands

Hi, I'm trying to make an SSH into a SGSN node and collect some commands printouts.:confused: I really don't know how this can be done. I think it must be like this: #!/bin/bash ssh user@192.168.88.10 Then I must enter the password, but I don't know how to do it, I tried with: echo... (3 Replies)
Discussion started by: nagomes
3 Replies

9. Shell Programming and Scripting

scripting an ssh session?

I know the root login/password for a machines, and I want to automate some commands like this from each: ssh root@remoteHost1 "tail /var/log/messages" ssh root@remoteHost2 "tail /var/log/messages" ssh root@remoteHost3 "tail /var/log/messages" ssh root@remoteHost4 "tail /var/log/messages" ssh... (2 Replies)
Discussion started by: jjinno
2 Replies

10. UNIX for Dummies Questions & Answers

is it possible to ssh within an ssh session?

i have a home network in which one computer can be sshed into from the internet. inside this ssh session, i cannot ssh into another computer on the internal network (LAN) i get the following error: pseudo-terminal will not be alocated because stdin is not a terminal any suggestions would be... (4 Replies)
Discussion started by: noamkrief
4 Replies
Login or Register to Ask a Question
Net::OpenSSH::Compat(3pm)				User Contributed Perl Documentation				 Net::OpenSSH::Compat(3pm)

NAME
Net::OpenSSH::Compat - Compatibility modules for Net::OpenSSH SYNOPSIS
use Net::OpenSSH::Compat 'Net::SSH2'; use Net::OpenSSH::Compat 'Net::SSH::Perl'; DESCRIPTION
This package contains a set of adapter modules that run on top of Net::OpenSSH providing the APIs of other SSH modules available from CPAN. Currently, there are adapters available for Net::SSH2 and Net::SSH::Perl. Adapters for Net::SSH and Net::SFTP are planned... maybe also for Net::SCP and Net::SCP::Expect if somebody request them. BUGS AND SUPPORT
This is a work in progress. If you find any bug fill a report at the CPAN RT bugtracker (https://rt.cpan.org/Ticket/Create.html?Queue=Net-OpenSSH-Compat <https://rt.cpan.org/Ticket/Create.html?Queue=Net-OpenSSH-Compat>) or just send me an e-mail with the details. Git repository The source code repository is at https://github.com/salva/p5-Net-OpenSSH-Compat <https://github.com/salva/p5-Net-OpenSSH-Compat>. My wishlist If you like this module and you're feeling generous, take a look at my Amazon Wish List: <http://amzn.com/w/1WU1P6IR5QZ42> Also consider contributing to the OpenSSH project this module builds upon: <http://www.openssh.org/donations.html>. SEE ALSO
Net::OpenSSH, Net::OpenSSH::Compat::SSH2, Net::OpenSSH::Compat::Perl. COPYRIGHT AND LICENSE
Copyright (C) 2011 by Salvador Fandino (sfandino@yahoo.com) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.1 or, at your option, any later version of Perl 5 you may have available. perl v5.14.2 2011-09-28 Net::OpenSSH::Compat(3pm)