Perl : Global symbol requires explicit package name Error while executing | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Perl : Global symbol requires explicit package name Error while executing

Shell Programming and Scripting


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-26-2013
scriptscript scriptscript is offline
Registered User
 
Join Date: Jan 2013
Last Activity: 30 January 2014, 11:03 AM EST
Posts: 74
Thanks: 21
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 03-26-2013
guruprasadpr's Avatar
guruprasadpr guruprasadpr is offline Forum Advisor  
Shrink...ing
 
Join Date: Jun 2009
Last Activity: 15 April 2014, 5:07 AM EDT
Location: India
Posts: 675
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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05: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 11:18 AM
Error in executing Perl script Pratik4891 Shell Programming and Scripting 11 09-12-2011 03:04 AM
Error executing shell command from a perl script voorkey Shell Programming and Scripting 5 03-30-2009 07:48 AM
change requires with perl learnbash Shell Programming and Scripting 2 09-19-2008 09:19 AM



All times are GMT -4. The time now is 11:09 AM.