Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Net::FTP and Microsoft FTP Service

by brewmaker (Novice)
on Mar 26, 2003 at 00:01 UTC ( [id://245819]=perlquestion: print w/replies, xml ) Need Help??

brewmaker has asked for the wisdom of the Perl Monks concerning the following question:

I am writing a script that uses Net::FTP to grab a file from a Win32 client. Everything works up to the point where it transfers the file. I tried the same script on a linux client and it worked. I'm not sure what the problem is. I am posting the ftp section of the script and the debug output.
#!/usr/bin/perl -w my $host = "192.168.10.155"; my $file_name = "/home/testuser/filestore/WWWMSEXP.TXT"; my $dir = "mail"; my $getname ="WWWMSEXP.TXT"; my $username = "testuser"; my $password = "secret"; use Net::FTP; $ftp = Net::FTP->new($host, Timeout =>40, Debug =>1) or die "can't con +nect to host"; $ftp->login($username,$password) or die "can't log in to host"; $ftp->cwd($dir) or die "can't change directory"; $ftp->ascii(); $ftp->get($getname,$file_name) or die "can't get file"; $ftp->quit();
The debug:
Net::FTP: Net::FTP(2.64) Net::FTP: Exporter(5.562) Net::FTP: Net::Cmd(2.21) Net::FTP: IO::Socket::INET(1.25) Net::FTP: IO::Socket(1.26) Net::FTP: IO::Handle(1.21) Net::FTP=GLOB(0x819dea4)<<< 220 Microsoft FTP Service Net::FTP=GLOB(0x819dea4)>>> user testuser Net::FTP=GLOB(0x819dea4)<<< 331 Password required for testuser. Net::FTP=GLOB(0x819dea4)>>> PASS .... Net::FTP=GLOB(0x819dea4)<<< 230 User testuser logged in. Net::FTP=GLOB(0x819dea4)>>> CWD mail Net::FTP=GLOB(0x819dea4)<<< 250 CWD command successful. Net::FTP=GLOB(0x819dea4)>>> TYPE A Net::FTP=GLOB(0x819dea4)<<< 200 Type set to A. Net::FTP=GLOB(0x819dea4)>>> PORT 192,168,10,221,9,213 Net::FTP=GLOB(0x819dea4)<<< 200 PORT command successful. Net::FTP=GLOB(0x819dea4)>>> RETR WWWMSEXP.TXT Net::FTP=GLOB(0x819dea4)<<< 150 Opening ASCII mode data connection for + WWWMSEXP.TXT(3180636 bytes). can't get file at ./mtest.pl line 18.
The file IS there and I can manually ftp to this client and get it.

Somebody hit me with a clue stick!

Thanks

Mike

Replies are listed 'Best First'.
Re: Net::FTP and Microsoft FTP Service
by defyance (Curate) on Mar 26, 2003 at 00:31 UTC
    Wow, everything looks correct to me, lets throw one more option into your debug. Your remote machine is a Win machine, from the looks of things, so after a cwd(), why not run $ftp->dir(); and look at the results in the debug. I'd do this just to make sure the file is *visable* to your program. Testing like that may help you track down the problem. Hope this helps a little.

    -- Can't never could do anything, so give me and inch, I'll make it a mile.

Re: Net::FTP and Microsoft FTP Service
by Thelonius (Priest) on Mar 26, 2003 at 01:02 UTC
    Instead of just dying, you should see what error ftp reports: $ftp->code(), $ftp->message() and, for good measure, $!.
      The error message produced by $! was "Bad file descriptor" which didn't help a great deal. I also bumped up the debug level in Net::FTP but didn't see anything new.

      I've had enough for now and decided to use wget because it works and I'm only grabbing the one file.

      I would like to try this again later when I have more time. Thanks to all who replied.

      -Mike
Re: Net::FTP and Microsoft FTP Service
by rah (Monk) on Mar 26, 2003 at 02:04 UTC
    Here's a possibility, and a way you might test.

    Are you sure you have enough permissions in the destination directory to create the file, i.e. the dir where you're running the script from? Is it posible when you tested manually you were in a different dir - one where you had write permissions?

    Crank debug up to 2 or 3 to capture more info.

Re: Net::FTP and Microsoft FTP Service
by thunders (Priest) on Mar 26, 2003 at 01:21 UTC
    I'm wondering if the problem is the path to your local file: "/home/testuser/filestore/WWWMSEXP.TXT" That looks like a unix path, Unless you have your windows computer set up with that kind of directory path, you will have issues. You will probably get a better picture of the exact error if you add the $! symbol to your die message, like so:
    $ftp->get($getname,$file_name) or die "can't get file: $!";

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://245819]
Approved by Thelonius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (4)
As of 2024-12-03 05:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found