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:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 11th, 2003, 06:20 AM
cgi_pro cgi_pro is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 29 cgi_pro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Net::FTP Download problem

Hello every one

I will make my question clear as much as possible.

I'm trying to code a script that uses Net::FTP module to download a certain file from my "some_domain.net" to my local "C:\" drive.

This file I'm trying to download is called "logo.gif". So I made the following code in my script:

#=============================================
use Net::FTP;

$ftp = Net::FTP->new("some_domain.net", Debug => 0);

$success = $ftp->login("MyUserName","MyPassword");

if($success){

print "Logged in ... ";

$ftp->get("logo.gif","logo.gif","C:\\");

$ftp->quit;


}else{
print "Login failed!<br>\n";
}
#=============================================

This is what happens now: When this code logs into my "some_domain.net" it places me in its default directory which is "/home/some_directory". I made sure that the file I'm seeking to download ("logo.gif") is in that "/home/some_directory". So I made sure I'm not trying to download something that is not there.


Now, having everything looking good, I ran the script and expected that I will receive my "logo.gif" in my "C:\" drive, but unfortunately I didn't find any!! So I concluded there is some problem with my code here, and that's why I'm asking anyone who has an idea of how to solve this problem of mine.

So can any one help? Thank you all

Reply With Quote
  #2  
Old September 11th, 2003, 06:29 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,505 ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 11 h 28 m 54 sec
Reputation Power: 1322
I haven't used Net::FTP myself but it doesn't look as if you're using the get() function correctly. From the docs:
Quote:
get ( REMOTE_FILE [, LOCAL_FILE [, WHERE]] )
Get REMOTE_FILE from the server and store locally. LOCAL_FILE may be a filename or a filehandle. If not specified, the file will be stored in the current directory with the same leafname as the remote file.

If WHERE is given then the first WHERE bytes of the file will not be transfered, and the remaining bytes will be appended to the local file if it already exists.

Returns LOCAL_FILE, or the generated local file name if LOCAL_FILE is not given. If an error was encountered undef is returned.


Try to catch an error from get():
Code:
my $filename = $ftp->get("logo.gif","logo.gif","C:\\"); 

if($filename) {
   print "Downloaded $filename\n";
}
else {
   print "Aaargh - the bloody thing failed again\n";
}


[edit]
From a quick read of the docs, it seems you should do it like this:
Code:
$ftp->cwd('C:\\');
$ftp->get('logo.gif');


[/edit]

Reply With Quote
  #3  
Old September 11th, 2003, 06:54 AM
cgi_pro cgi_pro is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 29 cgi_pro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the $ftp->cwd() method changes the directory on the domain.net server but not on my local machine. Despite this fact, I tried what you suggested just to make sure of what I know about the cwd() method, and it just did nothing as I expected. The problem still insists

Any more suggestions ?

Reply With Quote
  #4  
Old September 11th, 2003, 07:42 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,505 ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 11 h 28 m 54 sec
Reputation Power: 1322
Sorry - I misread that part. Did you check for the error from get()?

Reply With Quote
  #5  
Old September 11th, 2003, 08:49 AM
cgi_pro cgi_pro is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 29 cgi_pro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Yes I did and it told me it was successful. So I donno what is going wrong from my part

Reply With Quote
  #6  
Old September 11th, 2003, 08:55 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,505 ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 11 h 28 m 54 sec
Reputation Power: 1322
Leave out the last argument in get(). In the docs, 'WHERE' refers to which part of the file (i.e. number of bytes) to start, rather than where to put it locally. It should be saving the file in your current directory, rather than C:\

Reply With Quote
  #7  
Old September 11th, 2003, 05:54 PM
cgi_pro cgi_pro is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 29 cgi_pro User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
That's what I noticed, it saves it in the same directory my script is located in. But the big question is still here: How do I save it locally to my "C:\" drive? In other words: How do I use this get() to save this "/home/some_directory/logo.gif" from my hosted server to my "C:\" drive?

Reply With Quote
  #8  
Old September 12th, 2003, 02:16 AM
ishnid's Avatar
ishnid ishnid is offline
kill 9, $$;
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Sep 2001
Location: Dublin, Eire
Posts: 5,505 ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level)ishnid User rank is General 5th Grade (Above 100000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 2 Days 11 h 28 m 54 sec
Reputation Power: 1322
I would suggest either using chdir to change you current directory, or give a full path to your get() function as LOCAL_FILE, i.e.

Code:
my $filename = $ftp->get("logo.gif","C:\\logo.gif"); 

Reply With Quote
Reply

Viewing: Dev Shed ForumsSystem AdministrationFTP Help > Net::FTP Download problem


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 2 hosted by Hostway