HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl Net::FTP
Operating System - HP-UX
1832227
Members
2554
Online
110041
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
Forums
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
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
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
11-17-2005 05:31 AM
11-17-2005 05:31 AM
Does anyone know how to get around this
wildcard filename problem with perl.
The file I am picking up is in this format
with ";" in it.
TESTDFILE.TXT;11
When I try to do a "get" or "retr" it only
sees the string "1". I would be able to get
the file if I could figure out how to use
"command" with "mget".
$ftp->command (prompt) ;
$ftp->command (mget $file) ;
The result is this:
Net::FTP=GLOB(0x40012894)>>> NLST TESTDFILE*
Net::FTP=GLOB(0x40012894)<<< 150 Opening data connection for TESTDFILE*.
Net::FTP=GLOB(0x40012894)<<< 226 Closing data connection.
Net::FTP=GLOB(0x40012894)>>> prompt
Net::FTP=GLOB(0x40012894)>>> mget TESTDFILE*
Net::FTP=GLOB(0x40012894)>>> QUIT
Net::FTP=GLOB(0x40012894)<<< 500 Invalid command.
TESTDFILE.TXT;11
wildcard filename problem with perl.
The file I am picking up is in this format
with ";" in it.
TESTDFILE.TXT;11
When I try to do a "get" or "retr" it only
sees the string "1". I would be able to get
the file if I could figure out how to use
"command" with "mget".
$ftp->command (prompt) ;
$ftp->command (mget $file) ;
The result is this:
Net::FTP=GLOB(0x40012894)>>> NLST TESTDFILE*
Net::FTP=GLOB(0x40012894)<<< 150 Opening data connection for TESTDFILE*.
Net::FTP=GLOB(0x40012894)<<< 226 Closing data connection.
Net::FTP=GLOB(0x40012894)>>> prompt
Net::FTP=GLOB(0x40012894)>>> mget TESTDFILE*
Net::FTP=GLOB(0x40012894)>>> QUIT
Net::FTP=GLOB(0x40012894)<<< 500 Invalid command.
TESTDFILE.TXT;11
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2005 05:43 AM
11-17-2005 05:43 AM
Solution
You are making this more difficult by using the Net::Cmd:command method as opposed to simply using the ftp->get() method. I would do an ls to load the filenames into an array and then get() them one at a time. The nice thing about this approach is that get allows an optional LOCAL_FILENAME argument so that you can rename these ugly things "on the fly". The next nice thing is that you can check the status of each and every get.
The semicolon is probably causing you grief because you are not quoting your values.
The semicolon is probably causing you grief because you are not quoting your values.
If it ain't broke, I can fix that.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2005 06:29 AM
11-17-2005 06:29 AM
Re: Perl Net::FTP
I tried quotes.
$ftp->get ("$file");
If you know how to use "mget" with $FTP->
that would be great since "*" is valid with
mget and not get.
$ftp->get ("$file");
If you know how to use "mget" with $FTP->
that would be great since "*" is valid with
mget and not get.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2005 08:02 AM
11-17-2005 08:02 AM
Re: Perl Net::FTP
Forget mget. Do it the smart way leveraging your earlier use of ls:
# First create a function that will fix those dumb pathnames. This one will lowercase them as well but you should be able to figure out how to (un)fix that if you don't want it.
use Net::FTP;
use English;
use constant OKEY_DOKEY => 2;
sub fixname
{
my $fname = $_[0];
if ($fname =~ /(.+);(\d+)/)
{
$fname = lc($1);
}
return($fname);
} # fixname
...
...
# Wildcards will work so it's a good idea
# to load an array
my @tmp_array = $ftp->ls("*.txt");
my $stat = $ftp->status;
my $cc = 0;
if ($stat == OKEY_DOKEY)
{
my $i = 0;
my $newname = '';
while (($i <= $#tmp_array) && ($cc == 0))
{
$newname = fixname($tmp_array[$i]);
$ftp->get($tmp_array[$i],$newname);
$stat = $ftp->status;
if ($stat != OKEY_DOKEY)
{
$cc = ($stat != 0) : $stat : 242;
printf STDERR ("Get of %s failed (%d)\n",
$tmp_array[$i],$cc);
}
++$i;
}
}
else
{
$cc = ($stat != 0) ? $stat : 243;
printf STDERR
("ls of '%s' failed; (%d)\",$Pattern,
$cc);
}
ftp->quit;
exit($cc);
# First create a function that will fix those dumb pathnames. This one will lowercase them as well but you should be able to figure out how to (un)fix that if you don't want it.
use Net::FTP;
use English;
use constant OKEY_DOKEY => 2;
sub fixname
{
my $fname = $_[0];
if ($fname =~ /(.+);(\d+)/)
{
$fname = lc($1);
}
return($fname);
} # fixname
...
...
# Wildcards will work so it's a good idea
# to load an array
my @tmp_array = $ftp->ls("*.txt");
my $stat = $ftp->status;
my $cc = 0;
if ($stat == OKEY_DOKEY)
{
my $i = 0;
my $newname = '';
while (($i <= $#tmp_array) && ($cc == 0))
{
$newname = fixname($tmp_array[$i]);
$ftp->get($tmp_array[$i],$newname);
$stat = $ftp->status;
if ($stat != OKEY_DOKEY)
{
$cc = ($stat != 0) : $stat : 242;
printf STDERR ("Get of %s failed (%d)\n",
$tmp_array[$i],$cc);
}
++$i;
}
}
else
{
$cc = ($stat != 0) ? $stat : 243;
printf STDERR
("ls of '%s' failed; (%d)\",$Pattern,
$cc);
}
ftp->quit;
exit($cc);
If it ain't broke, I can fix that.
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
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP