SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: FTP with PERL

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    upstate NY, USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    FTP with PERL

    I'm trying to do 2 things.
    1. FTP files with PERL
    2. Display the file upload progress

    Here is some code I have tried and I get the message "system can't find the file path". I'm not sure how the $tmp and $afile variables should be used. $FORM{'fileUploadObj'} is the file to be uploaded.


    my $ftp="/usr/local/bin/ftp";
    #my $tmp='filename.txt';
    my $tmp=$FORM{'fileUploadObj'};
    #my $afile="somefile.pl";
    my $afile=$FORM{'fileUploadObj'};
    my $host = "192.168.1.101";
    my $dir = "C:\InetPub\Ftproot";
    open(FTP, "| $ftp -n $host >$tmp");
    print FTP "user username\n";
    print FTP "-password\n";
    print FTP "ls\n";
    print FTP "cd $dir\n";
    print FTP "get $afile\n";
    print FTP "binary\n";
    print FTP "quit\n";
    close(FTP);


    Any suggestions?

  2. #2
    SitePoint Enthusiast
    Join Date
    Mar 2001
    Location
    upstate NY, USA
    Posts
    47
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK I tried out the sample script below and I can't change directories (cwd) and can't upload files. I don't get any errors on login. Any suggestion? Anybody...


    use Net::FTP;
    $ftp = Net::FTP->new("some.host.name", Debug => 0);
    $ftp->login("anonymous",'me@here.there');
    $ftp->cwd("/pub");
    $ftp->get("that.file");
    $ftp->quit;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •