- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- perl error in ftp.pl
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2004 01:33 AM
тАО06-28-2004 01:33 AM
I am newbie in perl and trying to learn perl.
Just reading today's forum reagrding ftp script in perl i tried to run on my server but it is giving below error.
Hope procura have answer. Pl. tell me why erorr is coming.
Output of perl -MNet::FTP -le'print $Net::FTP::VERSION'
is 2.65
and perl -v shows:
This is perl, v5.8.0 built for PA-RISC1.1-thread-multi
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2002, Larry Wall
Binary build 806 provided by ActiveState Corp. http://www.ActiveState.com
Built 21:44:05 May 2 2003
Error message:
Global symbol "$ftp" requires explicit package name at ftp.pl line 16.
Global symbol "$destination" requires explicit package name at ftp.pl line 19.
Global symbol "$destination" requires explicit package name at ftp.pl line 19.
Execution of ftp.pl aborted due to compilation errors.
Below is the sfript:
#!/usr/local/bin/perl
use strict;
use warnings;
use Net::FTP;
use Net::Netrc;
my $server="x.x.x.x";
my $file="/home/tapas/test.txt";my $ftp = Net::FTP->new ($server, Timeout => 9000,Debug => 3) or die "$server: cannot connect: " .$ftp->message;$ftp->login or die "login: " .$ftp->message;
$ftp->binary or die "binary: ".$ftp->message;
$ftp->cwd ($destination) or die "cd $destination: ".$ftp->message;
open my $fh, "<:utf8", $file or die "open $file: $!";
$ftp->put ($fh, $file); # must give remote name.
close $fh or die "Cannot close file\n";
$ftp-quit;
Rgds
Tapas
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2004 01:45 AM
тАО06-28-2004 01:45 AM
Re: perl error in ftp.pl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2004 01:46 AM
тАО06-28-2004 01:46 AM
Solution1. You've not set $destination anywhere
2. The $ftp assignment was erroneously using the $ftp in the error message. If the connectr fails, you don't have an $ftp set, and hence cannot use it's methods.
#!/usr/local/bin/perl
use strict;
use warnings;
use Net::FTP;
use Net::Netrc;
my $server="x.x.x.x";
my $file="/home/tapas/test.txt";
my $destination = "/pub/foo/bar/baz";
my $ftp = Net::FTP->new ($server, Timeout => 9000,Debug => 3);
$ftp die "$server: cannot connect: $@";
$ftp->login or die "login: " .$ftp->message;
$ftp->binary or die "binary: ".$ftp->message;
$ftp->cwd ($destination) or die "cd $destination: ".$ftp->message;
open my $fh, "<:utf8", $file or die "open $file: $!";
$ftp->put ($fh, $file); # must give remote name.
close $fh or die "Cannot close file\n";
$ftp-quit;
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2004 01:48 AM
тАО06-28-2004 01:48 AM
Re: perl error in ftp.pl
_I_ am the one going to say: Never ever write scripts that should last without use strict and use warnings, and never remove these to get rid of (annoying) messages. It is far more likely that you made an error^Wtypo.
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2004 01:52 AM
тАО06-28-2004 01:52 AM
Re: perl error in ftp.pl
my $ftp = Net::FTP->new ($server, Timeout => 9000,Debug => 3) or die "$server: cannot connect: " .$ftp->message;
You are trying to die with a message including $ftp->message, where $ftp is undefined...
This is the first thing I see, but it can be something else.
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2004 01:53 AM
тАО06-28-2004 01:53 AM
Re: perl error in ftp.pl
Indeed you were the person I was referring to and hoped that it would be you explaining the error of my ways :)
See you later should beepz ever return!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2004 05:47 PM
тАО06-28-2004 05:47 PM
Re: perl error in ftp.pl
I am getting below error message while compiling. Line 17 is $ftp die "$server: cannot connect:$@";
syntax error at ftp.pl line 17, near "$ftp die"
Execution of ftp.pl aborted due to compilation errors.
Rgds
Tapas
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-28-2004 06:14 PM
тАО06-28-2004 06:14 PM
Re: perl error in ftp.pl
$ftp or die "FTP: cannot connect";
or something like that. The or was dropped somehow.
Enjoy, Have FUN! H.Merijn