FTP Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsSystem AdministrationFTP Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 13th, 2002, 12:17 AM
jonnyfolk jonnyfolk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 35 jonnyfolk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Net::FTP and 'one click' file transfer

I have been trying to understand the Net::FTP module with regard to a particular system I am trying to put into place.

I would like to be able to transfer a file from my server to another server by clicking a send button or link in my browser. Thus the server information (username, password etc) to where I am sending would be kept in a file or database on my server and the send button would create a connection between the servers, transfer the file and then disconnect.

However Net::FTP seems to require a command line input which would impair the desired 'one click' transfer I am looking for.

Is it possible to create a system like the one I describe using Net::FTP or other module, or am I flogging a dead horse?

Reply With Quote
  #2  
Old August 13th, 2002, 07:12 AM
d0g1e d0g1e is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: The Netherlands
Posts: 8 d0g1e User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to d0g1e
So you've got 2 servers (server A and server B). Server A contains a file that should be sent to server B.
This transfer should start when you click the button in your browser. The script that sends the file from A to B resides on server A.

I don't see a real problem here. If you store all the required information (hostname,user,password,sourcefile, targetfile) on server A, the script on server A could connect to server B and send the file, as soon as you click the button in your browser.

The command line input is just the commands that are needed to transfer the file from A to B, something like

Quote:
$ftp->put($sourcefile,$targetfile);


/edit

BTW: Check this site for more Net:FTP options:
http://www.perldoc.com/perl5.8.0/lib/Net/FTP.html

Reply With Quote
  #3  
Old August 13th, 2002, 04:13 PM
jonnyfolk jonnyfolk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 35 jonnyfolk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Thanks d0g1e for replying - you have given me the confidence to keep trying!

Assimilating all the info I have read I have the following assuptions and a script (these may be way off base but I feel I am getting close(r)!)

Remember my script is on ServerA and I am moving a file from Server A (serva) to Server B (servb). My assumption is that I have to call up and get the script from serva and then operate a sub routine to put the file on servb.

So far I am trying to get the file but I am getting the error message: 'couldn't change directory' (die message line 11). I wonder if anyone could check it and see if I have a problem there, or any other reason why the directory might not change?

PHP Code:
#!/usr/bin/perl -w
use Net::FTP;
use 
CGI::Carp qw(fatalsToBrowser warningsToBrowser);

$home="serva.com";
$username="self";
$password="pA88w0Rd";
$directory="/home/users/serva/public_html";
$filename="faq.htm";


$ftp Net::FTP->new("$home")    or die "Can't connect: $@\n";
$ftp->login($username$password)       or die "Couldn't login\n";
$ftp->cwd($directory)                   or die "Couldn't change directory\n";
$ftp->get($filename)                    or die "Couldn't get $filename\n";
#$ftp->put($filename)                    or die "Couldn't put $filename\n";
$ftp->quit

Reply With Quote
  #4  
Old August 13th, 2002, 04:33 PM
d0g1e d0g1e is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: The Netherlands
Posts: 8 d0g1e User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to d0g1e
The code looks fine.. (I can't try it at the moment)
Have you tried executing those commands by hand (using a ftp client?) How about adding a trailing / (slash) to the directory

Reply With Quote
  #5  
Old August 13th, 2002, 05:05 PM
jonnyfolk jonnyfolk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 35 jonnyfolk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Thanks once again for getting back to me.

I have just resolved the issue:
$directory="/home/users/serva/public_html";
did not require a path - I altered the line to:
$directory="public_html";
and the script moved on to die at 'Couldn'tÊgetÊfaq.htm'
I checked:
$filename="faq.htm"; and found it to be "faq.html".

I corrected it and the script went straight to Error 500. I assume that there's no problem with any of the steps so far but I need to go ahead and finish it!

Reply With Quote
  #6  
Old August 13th, 2002, 05:23 PM
d0g1e d0g1e is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: The Netherlands
Posts: 8 d0g1e User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to d0g1e
Strange.. absolute paths are supposed to work with ftp. Did the user have insufficient permissions?

anyway, add some http headers and you should be done! (I guess) have fun

Reply With Quote
  #7  
Old August 14th, 2002, 03:12 AM
jonnyfolk jonnyfolk is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 35 jonnyfolk User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Well, after a certain amount of fiddling around I got the script transferring server to server - I really appreciate your help. In the end it was straightforward but more of a confidence thing so you support was really useful.

As a postscript I tried using the /path/ of servb for the upload and that was not accepted either - a simple directory name was all that was required (both sites are operated by the same ISP - though on different servers). I may pose the question to the ISP if I get the time. Thanks once again.

Reply With Quote
  #8  
Old August 14th, 2002, 07:45 AM
d0g1e d0g1e is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Location: The Netherlands
Posts: 8 d0g1e User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to d0g1e
No problem

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > Net::FTP and 'one click' file transfer


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway