Questions tagged [expect.pm]

Expect.pm - Expect for Perl

Expect.pm is built to either spawn a process or take an existing filehandle and interact with it such that normally interactive tasks can be done without operator assistance. This concept makes more sense if you are already familiar with the versatile Tcl version of Expect.

30 questions
1
vote
0 answers

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: my $exp = new…
A. P.
  • 11
  • 1
1
vote
1 answer

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 ######################### use strict; use…
Manidip Sengupta
  • 3,573
  • 5
  • 25
  • 27
1
vote
1 answer

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->spawn($cmd) or die "Cannot spawn command\n";
Randomly Named User
  • 1,889
  • 7
  • 27
  • 47
1
vote
1 answer

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 = Net::OpenSSH->new("$username:$password\@$ip",…
ahmed
  • 19
  • 4
1
vote
1 answer

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 "strict subs" in use at /hom/perl/Net/SSH/Expect.pm line…
matoo
  • 11
  • 1
0
votes
1 answer

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 !; my $Passwd = `./ensite_passwd solidcore…
user746184
  • 105
  • 1
  • 10
0
votes
1 answer

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 warnings; use Path::Tiny qw(path); use…
luffy008
  • 37
  • 7
0
votes
1 answer

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 machine and the value from the command prompt…
Andrei Vieru
  • 154
  • 1
  • 11
0
votes
1 answer

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 output everything before first occurance of…
0
votes
1 answer

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 Automatically to script so that manual intervention is not…
0
votes
1 answer

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 same thing in Perl? I am sending below command on…
Bhushan Patil
  • 59
  • 1
  • 12
0
votes
1 answer

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 starts with @ character (example…
user3402702
  • 91
  • 1
  • 11
0
votes
1 answer

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: spawn id(22): Does `show \r\033[Kadmin@host> show…
user116969
  • 387
  • 1
  • 3
  • 8
-1
votes
1 answer

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 a different IP. So, this is how it works…
Gui O
  • 363
  • 4
  • 8
  • 22
-4
votes
1 answer

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 {$addr eq {}} continue; set timeout 180 …
1
2