31 questions
0
votes
0
answers
62
views
How to match ssh-keygen's "randomart" with Expect?
When trying to match the "randomart" part of ssh-keygen's output using Expect, expect() finds an empty string after the "randomart", but not the expected eof, but I don't ...
1
vote
1
answer
85
views
Attempting to access Expect object inside of Net::SSH::Expect gives an ERROR
Perl: attempting to access Expect object inside of Net::SSH::Expect gives an ERROR.
Example pseudo code:
my $m = Net::SSH::Expect->new(
host => 192.168.1.6,
user =&...
1
vote
1
answer
66
views
Expect.pm:expect() gives "Unexpected Subroutine" error
I'm extremely new to Perl and struggling with something. Recently, another developer left my company, and my boss has asked me to fix a Perl script that my former colleague wrote but did not document....
1
vote
1
answer
259
views
how to check if the Expect->spawn($command) is success?
I am passing an scp command in Expect->spawn($command), I am also passing the password or password + OTP based on a $object->expect().
Could you let me know if there is a way to determine if the ...
3
votes
1
answer
449
views
How do you properly wait for the prompt in the terminal before sending a command using expect for perl?
I'm very new to both Perl and expect and have been trying to figure out how to send a command when only the prompt appears. I know how to send a command after a certain output is displayed in the ...
1
vote
0
answers
224
views
Perl Expect: For ssh login, if a bad password fails, how to try another password?
When using Expect in Perl to automate ssh logins, if the 1st password fails, how can we try another password?
It's not hard to find the pure Expect examples to do so but cannot find one for Expect in ...
0
votes
1
answer
72
views
Perl expect code is not working for setting up password
I am using perl expect to enter password in an interactive program. Perl is outputting correct password but setting it something else.
#!/bin/perl
use Expect;
my $hostname = qx! /usr/bin/hostname !;...
1
vote
1
answer
348
views
Not able to execute command in remote machine Using Net::SSH::Expect
I wanted to make the remote connection and automate the change password of any user account in that remote machine so I am using Perl Net::SSH:: Expect module. My connection is happening but I'm not ...
0
votes
1
answer
291
views
Perl expect module not able to understand
I am new to Perl. I am using Perl Expect module to automate a simple prog but the output is mismatched.
This is my Perl code which I wanted to be automated
#!/usr/bin/perl
use 5.010;
use strict;
use ...
1
vote
0
answers
59
views
Expect.pm send trims the number sign
I'm trying to use Expect.pm on an old machine with perl 5.8.8.
It works but when I send a text that contains a "#" sign it is removed from the text.
Is there a way to escape/protect it?
Thanks
Sorry ...
3
votes
1
answer
323
views
Waiting on expect - until spawned program completes
I'm trying to use expect to spawn a program in an automation script in perl.
And I'm trying to decide how to wait on expect for this program to finish, since
- I can't rely on any string matching ...
0
votes
1
answer
374
views
Printing expect output without calling the variable
I'm trying to understand the
Expect
Perl module.
I want to take the value and the machine from $var, but I couldn't make my code work even if I used regular expressions.
I want to take from $var the ...
0
votes
1
answer
174
views
handling "--More--" in perl using Expect.pm
I have show command for a device with its Mac address, which i am executing in perl using Expect.pm.
The output of command is more than 100 line with --More-- at the bottom.
I am able to capture ...
1
vote
0
answers
788
views
Ssh using expect with threads?
Have you found solution any on how to ssh using expect with threads?
sub thDoWork {
#variables
my $thread_number = $_[0];
my $PassStoreQueue = $_[1];
my $Thread_Die = '';
my $...
-4
votes
1
answer
164
views
How can I convert expect script to perl scprit?
I never use perl script before. I have already done expect script, is there any way to convert it to perl?
I am trying to learn perl script right now.
Any idea could help!
foreach addr $addr {
if {$...
4
votes
1
answer
608
views
Spawn Expect from a perl thread
I am working on a script which needs to spawn an Expect process periodically (every 5 mins) to do some work. Below is the code that I have that spawns an Expect process and does some work. The main ...
0
votes
1
answer
64
views
Passing Parameteres to Interactive script programatically
We have an interactive script(Script 1) which asks for an IP Address and continues it's execution process. Script 1 is called from script2.
As we know the IP address we want to pass IP ...
1
vote
0
answers
1k
views
How to send a password with special characters by using Expect module?
I have a big problem with special characters of Perl.
I'm trying to establish a Telnet connection.
So, after the command "Telnet $ipAddress" I have to send the credentials.
I have done this way:
...
4
votes
1
answer
598
views
Automate and capture login prompt through perl's expect
I'm trying to automate a login prompt in Perl
I'm using SSHGetCredentials('login_prompt' => 1) to generate a login prompt which is a function of perl's Expect::SSH library
This is how my code ...
0
votes
1
answer
2k
views
How to capture the result of a command sent using Expect
I have to capture output of the send command when using Perl Expect module.
I know that in shell or Tcl I can use puts $expect_out(buffer); to capture the previously run command.
How can I do the ...
1
vote
1
answer
225
views
How can expect get out of infinite loop in a spawned process
Let me ask the question with a specific set of example. The 1st code, nlines.pl is as follows:
#!/usr/local/bin/perl
#########################
# print Hello world n times with n entered by a prompt
##...
5
votes
1
answer
197
views
Using expect in Perl, how to add options of ignoring case with method $object->expect()?
This is example found in perldoc:
$object->expect(15, '-re', "$str");
I want to add option 'i' to the match. This won't work:
$object->expect(15, '-re', qr/$str/i);
Do I have to ...
0
votes
1
answer
544
views
Perl Expect authentication with telnet
I have an active ssh session created with Expect 1.15. In this session I execute the following commands for a second level of authentication. Unfortunately i have to use a strange password which ...
1
vote
1
answer
483
views
Get session ID of spawned session using Expect in Perl
I'm using Expect to ssh. I want to know the Session ID of the spawned session. How do I do that?
This is my code:
my $addr = "10.101.10.102";
my $cmd = "ssh username@".$addr;
my $exp = Expect->...
0
votes
1
answer
252
views
How to disable control characters received with Expect.pm
I am using Expect.pm to connect with SSH to a remote server.
While connected, I'm sending commands via the Expect object, and I receive answers from the remote server with it's control characters:
...
3
votes
1
answer
1k
views
Perl ssh Password
I am trying to use perl to SSH in to a machine and issue a few commands...
my $ssh = Net::SSH::Perl->new($host);
$ssh->login($user,$pass);
my($stdout, $sterr, $exit) = $ssh->cmd($cmd);
print ...
2
votes
1
answer
311
views
Perl expect doesn't work after logout
A very simple code to connect to a server, run some commands, disconnect and run some more commands locally.
#!/usr/bin/perl
use strict;
use warnings;
use Expect;
my $timeout = 15;
my $password = "...
1
vote
1
answer
142
views
Displaying a portion of the configuration (--More)
I have got this error when i try to connect to my switch !
use Net::OpenSSH;
use warnings;
use Expect;
my $password = 'admin';
my $enable = '';
my $ip = '192.16.25.39';
my $username='user';
my $ssh = ...
-1
votes
1
answer
411
views
Perl Expect spawn limit
For performance issue and duration optimization, i want to know who limits my number of SSH connections.
A BASH script is calling X perl scripts. Each perl scripts spawn a new SSH connection towards ...
1
vote
1
answer
558
views
Perl: Bareword "exp_continue" in the lib Net::SSH::Expect
I am new in Perl. I downloaded the library Net::SSH::Expect v.1.09 and tried to use it by example.
When I try to execute a script I get the message:
Bareword "exp_continue" not allowed while "...
2
votes
1
answer
859
views
Get the output of a command executed via $self->send() on a remote host in Perl Expect module
I am using Expect module in Perl to do an interactive activity and execute a command on a remote machine. Request your help on this
Here are the steps I used
Do a switch user to another account.
...