Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

Perl : Global symbol requires explicit package name Error while executing

Shell Programming and Scripting


Closed Linux or Unix Question    
 
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: 16 November 2014, 9:00 AM EST
Posts: 75
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 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: 1 December 2014, 8:24 AM EST
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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 10:48 PM.