tags:

views:

88

answers:

1

I need to move or copy a simple text file from one web site to another web site. I have administrator rights to both web sites. The first web site has a large data file (again, just a text file), certain records are selected and written to a team file (for entry into a tournament). Next I go through paypal and pay for the entries. The second site is for the the club running the tournament and I use IPN to return to a script on their site and if it verified, I add the team memebers into the master file for the tournament. I am limited to the ONE IPN script on the tournament site because I have a ton of other entries that come in from all over. The first site has the rosters for the state and no need to type all that data from each club, use the rosters like I use for all the non-paypal tounamenmts. I can ftp the team file to the second server and place it in the folder just like it was created from scratch from that server originally and everything should go fine but I took the examples and tried them and nothing. Here's the code section:

my  $custom = $in->param('custom');
my  $filename = "$ENV{DOCUMENT_ROOT}/database/$custom";

my  $usjochost = '208.109.14.105'; 
my  $okserieshost = '208.109.181.196'; 

my  $usjocuser = 'teamentry'; 
my  $okseriesuser = 'okwaentry'; 

my  $usjocpw   = 'Password1'; 
my  $okseriespw   = 'Password1'; 

my  $file = $custom; 

my  $usjocpath ='/home/content/u/s/j/usjoc/html/database/'; 
my  $okseriespath ='/home/content/o/k/s/okseries/html/database/'; 

$ftp = Net::FTP->new($okserieshost, Debug => 0)  or die "Could not connect to '$okserieshost': $@"; 

$ftp->login($okseriesuser, $okseriespw) or die sprintf "Could not login: %s", $ftp->message; 

#$ftp->cwd(/database)  or die sprintf "Could not login: %s", $ftp->message; 
$ftp->get($filename);

#$ftp = Net::FTP->new($usjochost, Debug => 0)  or die "Could not connect to '$usjochost': $@"; 

$ftp->quit;

I NEED to READ the file on the first web site (okseries.com) and write the file on the second web site (usjoc.com). I have no problem reading and writing the file on the server, is sending the file to the second server. HELP! I'm not a genius at PERL.

+2  A: 

Hi,

i tested the code you made and implemented to it, the follow code will connect to your first host, okserieshost and get the $filename from database folder, verify if the file was downloaded (if not it will end operations).

#!/usr/bin/perl

use Net::FTP;

my  $path     = '/public_html/api';
my  $filename = 'index.php';

my  $host = '';
my  $user = '';
my  $pass = '';

print "Content-type: text/html\n\n"; 
$ftp = Net::FTP->new($host, Debug => 0)  or die "Could not connect to $host: $@";
print "<pre>".$ftp->message ."</pre><br>\n";
$ftp->login($user,$pass) or die sprintf "Could not login: %s", $ftp->message;
print "<pre>".$ftp->message ."</pre><br>\n";
my $cur = $ftp->pwd();
my $new = $ftp->cwd($path);

if ($cur == $new) {
    $ftp->quit;
    print "Directory not found, exiting.\n";
} else {
    if ($ftp->size($path.'/'.$filename) >= 0) {
        $ftp->get($path.'/'.$filename) or die $ftp->message;
        print "<pre>".$ftp->message ."</pre><br>\n";
        print "File downloaded with success." if (-e $filename);
    } else {
        print "File not found.\n";
    }
}

$ftp->quit;

i've changed the code a little you can put this file on usjoc.com and run it on the browser it wil display every step of the communication until it gets the file from okseries.com. All you have to do is change $path to the path of where the file is but do not end the directory name with a / filename in case on $filename $host = ftp ip or hostname $uesr and $pass i guess you know what goes in

response from the url you asked to be viewed:

USJOC Entry Form on



The Club file name is EdmondSkunks1T.db
/home/content/o/k/s/okseries/html/database/EdmondSkunks1T.db
Supposedly opened /home/content/o/k/s/okseries/html/database/EdmondSkunks1T.db
Back to USJOC
Prix
http://okseries.com/cgi/EntryTEST.cgi?custom=EdmondSkunks1T.dbthat is a file on okseries that I want to upload onto usjoc.com. I work through a vpn that may be causing me problems, could you check it with my URL?
Jerry Scott
The response of your url was:The Club file name is EdmondSkunks1T.db/home/content/o/k/s/okseries/html/database/EdmondSkunks1T.dbSupposedly opened /home/content/o/k/s/okseries/html/database/EdmondSkunks1T.db i will update this response on my reply so you can see it formated.
Prix
Can you describe a little more what happens when you run the code, are you running it on the browser or shell (command line) ? are you running it on the server you want the file to go to or some where else ?Do you have admin access on the server that holds usjoc.com or is it under cpanel or any panel that allows you to use cronjob ? if so you could use a simple ftp from there to retrieve the file instead of having to open it from one place and put it there. Using cronjob you wich is a schedule tool from linux you can setup a time for it to run every minute or hour or day...
Prix
I am the admin on both servers. I execute the cgi on the server.The team makes the roster to enter, thats saved in the text file (EdmondSkunks1T.db), I NEED that file sent over to USJOC.COM into the /database/ folder under the same name. That file is accessed by the IPN script on USJOC.COM coming back from paypal. make sense?? I'll be gone awhile, you can reach me at jerry dot scott at faa dot gov with email and I can explain further.
Jerry Scott
the EdmondSkunks1T.db text file is in the database folder on okseries.com right now and it's not on usjoc.com, that's how I'll know if it get's there when it shows up in ws_ftp I used to upload programs etc to both sites.
Jerry Scott
FORGOT TO ADD .. THANK YOU :)
Jerry Scott