|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 ![]() |
|
#2
|
||||
|
||||
|
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:
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]
__________________
~ishnid; Have you tried: [ search.cpan.org | perldoc | Java API | mysql.com | google ] Apostrophes are NOT used for possessive pronouns or for noun plurals, including acronyms. |
|
#3
|
|||
|
|||
|
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 ? |
|
#4
|
||||
|
||||
|
Sorry - I misread that part. Did you check for the error from get()?
|
|
#5
|
|||
|
|||
|
Yes I did and it told me it was successful. So I donno what is going wrong from my part
![]() |
|
#6
|
||||
|
||||
|
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:\
|
|
#7
|
|||
|
|||
|
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?
|
|
#8
|
||||
|
||||
|
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");
|
![]() |
| Viewing: Dev Shed Forums > System Administration > FTP Help > Net::FTP Download problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|