Hi
Can someone please tell me how to compile a perl script which is
calling global variables and then how should the executable be used?
I have created a AIX shell script (tool.sh) that parses a couple of
files to export few global variables and then shows the end result.
Now i call these variables in an ftp script (ftp.pl) which i have
written in perl. When I run the master script (tool.sh) with ftp.pl,
it runs perfectly fine...but I wanted to compile ftp.pl to create and
ftp.out and then use ftp.out in the tool.sh script.
When I compile ftp.pl with perlcc, I am getting an executable which is
throwing the following error on execution.
# ./ftp.out
Can't use an undefined value as a HASH reference at ftp.pl line 3.
My ftp.pl is:
#!/usr/bin/perl
$ftpip=$ENV{'IP'};
$ftpserver=$ENV{'MNAME'};
$ftpusername=$ENV{'USER'};
$ftppass=$ENV{'PASS'};
$ftploc=$ENV{'LOC'};
use Net::FTP;
if($ftp = Net::FTP->new("$ftpip",Debug => 0)){print "Logging into
server $ftpserver \n";}else{print "could not login \n";exit;}
if ($ftp->login("$ftpusername","$ftppass")) { print "Username and
Password ACCEPTED\n"; } else { print "could not log into server with
Username and Password.
Exiting!\n"; exit; }
if ($ftp->pasv) { print "Passive mode entered successfully\n"; } else
{print "Could not switch to pasive mode.\n"; }
if ($ftp->cwd("$loc")) { print "Changed to the directory $loc without
any trouble \n"; } else { print "Could not change to $loc directory
\n"; }
if ($ftp->put("/home/ashish/perl/touch.tst","$ftploc/touch.test"))
{print "file transferred properly \n"; } else { print "could not
transfer file \n";}
$ftp->quit;
i think the error is because of global variables. Can someone please
tell me how to compile a perl script which is calling global variable?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/