CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Getting error while running a perl script

 



peacepanda3
New User

Jan 29, 2015, 1:26 AM

Post #1 of 4 (3025 views)
Getting error while running a perl script Can't Post

Hi All,

I am running an scp script using perl the script is as


Code
#!/bin/perl 
use lib qw (/WOOSH/cgi-bin);
use CGI qw(:cgi-lib);
use General;
use strict;
use Net::FTP;
use Net::SCP;
use Net::SCP::Expect;
sub scp_backup{
my $n = scalar(@_);
if ($n == 7)
{ my $dest="/my/remote/location/";

my $testfile = "/pah/to/my/file/testing.txt";
my $scpe = Net::SCP::Expect->new(
host => $ip,
user => $username,
password => $password,
auto_yes => 1,
verbose => 1,
debug => 1,
timeout_auto => 2,
);
die "can't scp: $!\n" unless $scpe->scp($testfile, $dest);
}
else
{
print "\nNot enough args\n\n";
}
print "\nTotal items passed:$n\n";
}
$name = "testuser";
$tfr_type = "scp";
$ip = "XX.XX.XX.XX";
$username = 'testuser_name';
$password = 'testpass';
&scp_backup($name, $tfr_type, $ip, $username, $password,1,1);



When I run the script I am getting the following error



Can't locate object method "new" via package "Expect" (perhaps you forgot to load "Expect"?) at /usr/opt/perl5/lib/site_perl/5.8.2/Net/SCP/Expect.pm line 190.

Can some one tell me why am I getting the error.The expect module is already installed on my server.

(This post was edited by FishMonger on Jan 29, 2015, 6:04 AM)


FishMonger
Veteran / Moderator

Jan 29, 2015, 6:14 AM

Post #2 of 4 (3018 views)
Re: [peacepanda3] Getting error while running a perl script [In reply to] Can't Post

Please use the code tags around all code you post. I've added them here for you this time.

What version of Expect and Net::SCP::Expect do you have installed?

Try adding Expect to your list of use statements to see if that solve the issue.


(This post was edited by FishMonger on Jan 29, 2015, 6:16 AM)


peacepanda3
New User

Jan 29, 2015, 10:03 PM

Post #3 of 4 (2996 views)
Re: [FishMonger] Getting error while running a perl script [In reply to] Can't Post

The versions of Expect (1.21) and Net::SCP::Expect (0.16).

Added expect to the use list but didnt work




FishMonger
Veteran / Moderator

Jan 30, 2015, 7:12 AM

Post #4 of 4 (2973 views)
Re: [peacepanda3] Getting error while running a perl script [In reply to] Can't Post

Saying "didnt work" is a very poor problem statement. Did you receive the exact same error, or a different error?

I'm on a Windows system right now so I can't do any testing using Expect.

Expect v1.21 is fairly old (Aug 2007). The current release is 1.32 which came out in Oct 2014. You should upgrade to that newer version.

The error message indicates that you're using perl v5.8.2 is that right? That is VERY VERY old (circa 2003). You should defiantly upgrade perl.

Start with the basics in your test script. By that I mean to strip out everything that is not needed and instead of using Net::SCP::Expect, start off by using the Expect module directly.

If that works, then add Net::SCP::Expect and retest.


(This post was edited by FishMonger on Jan 30, 2015, 7:16 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives