- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to get files from dir using use Net::FTP modul...
Operating System - HP-UX
1820635
Members
1785
Online
109626
Solutions
Forums
Categories
Company
Local Language
back
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
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
07-14-2009 04:56 AM
07-14-2009 04:56 AM
How to get files from dir using use Net::FTP module in perl
Hi All,
I have written code to get all ZIP files from FTP server and put in Unix.
But i am not able to navigate from one dir to other.
FTP Server(Windows) Dirstrucre is :
/root/';
/root/dir1/:
Z1.zip,z11.zip ..
/root/dir2/:
Z1.zip,z11.zip ..
Now i need to get all files one by one.
$dirpath = '/root/';
$ftp = Net::FTP -> new('X.X.X.X', Port => 21, Debug => 0);
$ftp->login('xxx','0000');
$ftp->binary();
$ftp->cwd($dirpath) or die "Can Not Change Dir";
foreach my $name ('/root/dir1', '/root/dir2') {
$ftp->cwd($name) or die "Can not change the dir";
foreach my $file($ftp->ls)
{
next unless $file=~/.*\.zip/;
$ftp->get($file);
printf("Sucessfully copied files");
}
}
It is not able to change the dirs in FTP server. Can some one please tell what is the problem.
Thanks
I have written code to get all ZIP files from FTP server and put in Unix.
But i am not able to navigate from one dir to other.
FTP Server(Windows) Dirstrucre is :
/root/';
/root/dir1/:
Z1.zip,z11.zip ..
/root/dir2/:
Z1.zip,z11.zip ..
Now i need to get all files one by one.
$dirpath = '/root/';
$ftp = Net::FTP -> new('X.X.X.X', Port => 21, Debug => 0);
$ftp->login('xxx','0000');
$ftp->binary();
$ftp->cwd($dirpath) or die "Can Not Change Dir";
foreach my $name ('/root/dir1', '/root/dir2') {
$ftp->cwd($name) or die "Can not change the dir";
foreach my $file($ftp->ls)
{
next unless $file=~/.*\.zip/;
$ftp->get($file);
printf("Sucessfully copied files");
}
}
It is not able to change the dirs in FTP server. Can some one please tell what is the problem.
Thanks
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2009 12:03 PM
07-14-2009 12:03 PM
Re: How to get files from dir using use Net::FTP module in perl
Hi:
If the directory doesn't exist on the _remote_ server, the $ftp->cwd()' will fail.
Try this test case:
# ./myftp
#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP;
my $ftp = Net::FTP->new('x.x.x.x', Port=>21, Debug=>1) or die "Open failed\n";
$ftp->login('acct','pass') or die "Login failed\n";
for my $path qw( /tmp /var /dummydir ) {
$ftp->cwd($path) or warn "failed cd to '$path'\n", $ftp->message, "\n";
}
...
Regards!
...JRF...
If the directory doesn't exist on the _remote_ server, the $ftp->cwd()' will fail.
Try this test case:
# ./myftp
#!/usr/bin/perl
use strict;
use warnings;
use Net::FTP;
my $ftp = Net::FTP->new('x.x.x.x', Port=>21, Debug=>1) or die "Open failed\n";
$ftp->login('acct','pass') or die "Login failed\n";
for my $path qw( /tmp /var /dummydir ) {
$ftp->cwd($path) or warn "failed cd to '$path'\n", $ftp->message, "\n";
}
...
Regards!
...JRF...
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP