Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

$ftp not connecting to server

by IronCore (Initiate)
on Oct 09, 2009 at 18:09 UTC ( #800355=perlquestion: print w/ replies, xml ) Need Help??
IronCore has asked for the wisdom of the Perl Monks concerning the following question:

<body> Hi monks,
I have some perl code that I use to ftp files from our mainfarme but
when I try to use the same code to connect to a windows ftp server it won't
connect.  The server address is good I've connected to it using my
mainframe ftp program.
Any ideas?

Perl code
open(FTP_WORK, ">@FTP_cmnd_file"); $oldHandle = select(FTP_WORK); print("open windows.ftp.server \n"); print("my\\userid \n"); print("password \n"); print("cd '/download' \n"); print("get '$downfile' $ftpFile \n"); print("bye \n"); close(FTP_WORK); $_ = `ftp -s:@FTP_cmnd_file > @FTP_log_file`;

I also tried this code I got from your site, It didn't work ether.


$ftp = Net::FTP->new( $server, Passive => 1, Debug => 0 ) or die $@;
messages retruned.
ftp> ftp> open window.ftp.server Invalid command.

thanks. </body>

Comment on $ftp not connecting to server
Select or Download Code
Re: $ftp not connecting to server
by zwon (Monsignor) on Oct 09, 2009 at 19:01 UTC
    $ftp = Net::FTP->new( $server, Passive => 1, Debug => 0 ) or die $@;
    messages retruned.

    What messages were returned? Can you set Debug => 1?

Re: $ftp not connecting to server
by hippsta (Acolyte) on Oct 09, 2009 at 19:03 UTC
    Windows FTP generally operates in Active mode.
    This is more a system administration issue, than with perl per se.
    GL! :)
    Respectfully,

    Brother Hippsta
Re: $ftp not connecting to server
by vitoco (Pilgrim) on Oct 09, 2009 at 19:14 UTC

    Some servers requires you to send the username and password using user and pass commands.

Re: $ftp not connecting to server
by derby (Abbot) on Oct 09, 2009 at 19:17 UTC

    Hmmm ... creating a tmp file and exec'ing it isn't very perlish. Using what you have, your Net::FTP should look like this:

    #!/usr/bin/perl use strict; use warnings; use Net::FTP; my $ftp = Net::FTP->new( "windows.ftp.server", Debug => 0 ) or die "Cannot connect to windows.ftp.server: $@"; $ftp->login( "userid","password" ) or die "Cannot login ", $ftp->message; $ftp->cwd( "/download" ) or die "Cannot change working directory ", $ftp->message; $ftp->get( $downFile, $ftpFile ) or die "get failed ", $ftp->message; $ftp->quit;
    (and that's pretty much straight out of the docs).

    -derby

      derby,
      I tried your code and it failed to connect.
      Do I have to define the server to windows somewhere?
      Like with ODBC for databases.
      I put my mainframe server name (which is an alias) in your code and it does connect.
      I'm a mainframer who has been forced at gun point to dance on the small platform side :-) so i'm not familiar with all of the ins and outs of window.
      thanks.

        IronCore the windows server name needs to resolve and there needs to be an ftp server running there. Have you tried connecting to the machine with a normal ftp client?

        -derby

      derby,
      I forgot to respond to your tmp file comment.
      The program that sample came from is used to ftp many different files depending on passed parms.
      If there's a cleaner way to do it I'm certainly open to it.
      I do need to save the ftp output messages to a file though.
      thanks,

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2014-07-13 11:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (249 votes), past polls