Need help: perl script to FTP

From: FLOTServer (flot)
Date: 08/26/04

  • Next message: Chris Cole: "Re: Need help: perl script to FTP"
    Date: Thu, 26 Aug 2004 00:21:53 -0400
    
    

    Here's my problem: I run a gameserver that runs the game "Medal of Honor".
    On the game server is log file which contains all of the data from the
    players for that day (kills, deaths, etc...). I have a perl script that runs
    on my webserver, which is supposed to login to the gameserver and download
    the log. The problem is that when it gets to the part where it needs to
    download the file, it aborts. The gameserver FTP requires I use port 24 and
    passive mode. Here's my script:

    ====start
    #!/usr/bin/perl

    ##Game server IP
    $ftpserver = "66.36.252.88:24";

    ##Login username
    $ftpusername = "username";

    ##Login password
    $ftppass = "password";

    ##Logfile folder on Game Server (no trailing slash)
    $cwdd = "/mainta";

    ##Logfile name on the gameserver
    $logfile = "qconsole.log";

    ##Logfile name saved on the webserver
    $logname = "qconsole.log";

    ##Local path on webserver (no trailing slash)
    $logpath = "/public_html/mohstats/logs";

    ##NO NEED TO EDIT ANYTHING BELOW THIS LINE

    use Net::FTP;

    if ($ftp = Net::FTP->new("$ftpserver", Debug => 0)) { print "Logging in to
    server\n"; } else { print "could not find server! Exiting\n";
    &send("Transfer FAILED. Could NOT connect to $ftpserver", "Transfer
    FAILED"); exit; }

    if ($ftp->login("$ftpusername","$ftppass")) { print "Username and Password
    ACCEPTED\n"; } else { print "could not log into server with Username and
    Password. Exiting!\n"; &send("Transfer FAILED. Could NOT connect to
    $ftpserver with the Username And Password provided - Authentication error.",
    "Transfer FAILED"); exit; }

    if ($ftp->pasv) { print "Passive mode entered successfully\n"; } else {
    print "Could not switch to pasive mode.\n"; }

    if ($ftp->cwd("$cwdd")) { print "Changed to the directory without any
    trouble - DOWNLOADING\n"; } else { print "Could not change to the
    appropriate directory, uploading anyway\n"; }

    if ($ftp->ascii) { print "Changed to ASCII Mode No Problem\n"; } else {
    print "Could not change to ASCII mode $!\n"; exit; }

    if ($ftp->get("$logfile","$logpath/$logname")) { print "Everything appears
    ok with the Transfer\n"; } else { print "Can not Transfer file $!\n
    EXITING\n", $ftp->message, "\n"; &send("Transfer FAILED. Could NOT Transfer
    from $ftpserver. Error message returned from server is: $1", "Transfer
    FAILED"); exit; }

        $ftp->delete("$logfile");
        $ftp->quit;

     print "File Transferred OK!\nFinished\n";
    ====end

    Here's the error I get when the script runs:

    Undefined subroutine &main::send called at
    /home/flot/public_html/cgi-bin/ftp.pl line 40.
    Logging in to server
    Username and Password ACCEPTED
    Passive mode entered successfully
    Changed to the directory without any trouble - DOWNLOADING
    Can not Transfer file
     EXITING
    Cannot retrieve. Failed. Aborting

    Any idea what is going wrong?

    -- 
    Visit the .:|FLOT|:. Spearhead Server at 66.36.252.88!
    http://www.flotserver.net
    

  • Next message: Chris Cole: "Re: Need help: perl script to FTP"

    Relevant Pages

    • Need help: perl script to FTP
      ... I run a gameserver that runs the game "Medal of Honor". ... On the game server is log file which contains all of the data from the ... "Transfer FAILED"); exit;} ...
      (comp.lang.perl)
    • [NEWS] Gamespy CD-Key Validation System "CD-Key In Use" DoS
      ... An attacker can sniff all the valid CD-key authorizations sent from his ... server to the GameSpy master server when a player joins his match. ... to the game server. ... With client is meant the game client so the users/gamers, ...
      (Securiteam)
    • /dev/null/nethack Tournament 2006 Announcement
      ... We're currently putting the finishing touches on this year's Challenge patch, so folks interested in hosting this year will need to wait till we announce that the game server kit is ready for download. ... the Tournament is open to anyone who'd like to play. ... We're also open to anyone who'd like to volunteer to run a game server since, though we have a few servers lined up around North America so far, play can be slow across the transoceanic links. ...
      (rec.games.roguelike.nethack)
    • OM corrects a major personal oversight...
      ... purpose and one purpose alone: ... Carpenter - Has a flaky video card that refuses to switch video modes ... Cooper - My overloaded music server, more drives than the P/S knows ... I just named a game server after Jose Jimenez. ...
      (sci.space.history)
    • /dev/null/nethack Tournament 2007 Announcement
      ... We're currently putting the finishing touches on this year's Challenge patch, so folks interested in hosting will need to wait till we announce that the game server kit is ready for download. ... the Tournament is open to anyone who'd like to play. ... We're also open to anyone who'd like to volunteer to run a game server since, though we have our own servers in California, play can be slow from other parts of the continent and across the transoceanic links. ...
      (rec.games.roguelike.nethack)