in reply to FTP within PERL script WITHOUT NET::FTP?
This should work with a gateway, this is working code with some modified names.
Update:Posted this real early this morning, didn't really put any meaningful comments. Note that the above is only tested on a unix box (HPUX), but should work as is on any *nix. The contents of "$StatusFile" would look about like:my $gsRemoteMachine = "ftp.site.com"; my $gsRemoteDir = "/"; my $gsFtpId = "username"; my $gsFtpPwd = "password"; my $gsGateMachine = "gateway.site.com"; # ftp gateway my $gsGateConnect = "\@$gsRemoteMachine "; # remote machine connect +id for gateway my $gsRemoteMachine = $gsGateMachine; my $gsFeedsDir = "/mypath/"; my $gsFeedFile = "myfile"; system("ftp -n $RemoteMachine <<EOF> $StatusFile 2>&1\n\nuser $gsFtpId +$gsGateConnect $gsFtpPwd\nverbose\n$gsFtpMode\nput $gsFeedsDir$gsFeed +File $gsRemoteDir$gsFeedFile\nclose\nbye\nEOF");
Verbose mode on. 200 Type set to I. 200 PORT command successful. 150 Opening BINARY mode data connection for xxxxxxx.gz. 226 Transfer complete. 720203 bytes sent in 5.00 seconds (140.57 Kbytes/s) 221- Goodbye... 221 Total bytes retrieved: 0 stored: 720203
Without Net::FTP one needs to open the $StatusFile and read it in to determine if it succeeded/failed.
I have more on this very issue, in a previous node here Improving an FTP process that discusses FTPing this way, and why I migrated such code to Net::FTP
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: FTP within PERL script WITHOUT NET::FTP?
by c-era (Curate) on Nov 13, 2000 at 21:35 UTC |