F
FLOTServer
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?
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?