Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Perl : Global symbol requires explicit package name Error while executing

Shell Programming and Scripting


Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 03-26-2013
scriptscript scriptscript is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 25 January 2016, 10:42 PM EST
Posts: 82
Thanks: 24
Thanked 0 Times in 0 Posts
Perl : Global symbol requires explicit package name Error while executing

I have executed the below perl script for copying the file from one server to another server using scp.


Code:
#!/usr/bin/perl -w
use Net::SCP::Expect;
use strict;
$server= "x.x.x.x";
my $source = "/mypath/mypath";
my $destination = "/home/";
print "Login...Starting scp...";
$user="admin";
$password="admin";
print "Login...Starting scp...";
my $scpe = Net::SCP::Expect->new(host=>$server, user=>$user, password=>$password, recursive=>'1', auto_yes => '1', auto_quote => '0');
$scpe->scp('x.x.x.x:/mypath/*.csv',$destination);
print "SCP complete\n";

But I have received the below errors

Code:
DC01INETSRV2[Johng]/s0/home>perl sftptest.pl
Global symbol "$server" requires explicit package name at sftptest.pl line 11.
Global symbol "$user" requires explicit package name at sftptest.pl line 15.
Global symbol "$password" requires explicit package name at sftptest.pl line 16.
Global symbol "$server" requires explicit package name at sftptest.pl line 20.
Global symbol "$user" requires explicit package name at sftptest.pl line 20.
Global symbol "$password" requires explicit package name at sftptest.pl line 20.
Execution of sftptest.pl aborted due to compilation errors.

COuld anyone please help me on the above errors.

Thanks in advance...

Regards,
J
Sponsored Links
    #2  
Old Unix and Linux 03-26-2013
guruprasadpr's Unix or Linux Image
guruprasadpr guruprasadpr is offline Forum Advisor  
Shrink...ing
 
Join Date: Jun 2009
Last Activity: 6 June 2016, 11:49 AM EDT
Location: India
Posts: 676
Thanks: 30
Thanked 215 Times in 214 Posts
All variables shown in the error are used as global variables. Make them lexical using "my".


Code:
my server= "x.x.x.x";
my $user="admin";
my $password="admin";

Guru.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem when trying to remove a package using rpm command - error: package is not installed g_p Emergency UNIX and Linux Support 4 04-04-2012 06:36 AM
Can't install rpm package with --prefix in new path.Error: package is not relocatable g_p UNIX for Dummies Questions & Answers 1 04-01-2012 12:18 PM
Error in executing Perl script Pratik4891 Shell Programming and Scripting 11 09-12-2011 04:04 AM
Error executing shell command from a perl script voorkey Shell Programming and Scripting 5 03-30-2009 08:48 AM
change requires with perl learnbash Shell Programming and Scripting 2 09-19-2008 10:19 AM



All times are GMT -4. The time now is 08:16 PM.