I am using $ftp->put to upload file to ftp server but it is not working...
Here's the script
#!/usr/bin/perl -w
use strict;
use Net::FTP;
my $ftp = Net::FTP->new("ftp.mydomain.com") or die "INFO: Cann't connect: $@\n";
$ftp->login("login","xxxx") or die "INFO: Couldn't login\n";
$ftp->cwd("/dir/myarea") or die "INFO: Couldn't change directory to \"/dir/myarea"\n";
$ftp->put("hehe.txt") or die "WHAAAAAAAAT THE HELL";
If this page was useful to you, please click to help others find it:
More Articles by anonymous
Have you tried Searching this site?
Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates
This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.
Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.
Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.
We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.
Click here to add your comments
Fri Jun 30 11:25:20 2006: TonyLawrence
Well, as shown it would fail at
$ftp->cwd("/dir/myarea") or die "INFO: Couldn't change directory to \"/dir/myarea"\n";
because you didn't quote the " after myarea.
But other than that it looks fine.
But you didn't bother to say HOW it fails? Can you "put" a file manually if you just ftp from the command line?
Sun Jul 2 14:54:41 2006: rakesh
It failed on put command.... Yes I can put manually upload the file.
Sun Jul 2 20:18:14 2006: TonyLawrence
Do you have to do anything unusual? What do you use for a client? Can you do $ftp->dir or $ftp->get etc? Does it require PASV mode?
Mon Jul 3 07:21:51 2006: rakesh
I can do $ftp->cwd; I can change directory. Previously the same script is used to work. I wouldn't blame that anything is wrong in the script. Then our company moves to new office and some settings might have changes. And the script is not working after that.
Some issues with the settings. I got one link in the net.. but couldn't get the meaning though.
http://forums.devshed.com/ftp-help-113/net-ftp-ftp-put-problem-142860.html
Mon Jul 3 10:38:42 2006: TonyLawrence
Sounds like that guy was confusing himself with a cgi script. He was trying to upload from his home pc to his webserver -
Replace "WHAT THE HELL" with $ftp->message
What does that say?
Tue Jul 4 10:42:17 2006: rakesh
No, I am not loading anything from my home pc.
we have redhat7.2 machine from where files are uploaded. our workstation has fedora4 installed in it.
The script works with fedora4 machine. But when I ssh to to redhat7.2 machine and run the same script it fails on $ftp->put command.
I changed the "what The hell" message to $ftp->message.
It dumps following message on the screen..........
"Illegal PORT command"
But again the same script works fine with fedora4 machine and the file is uploaded also.
Anyway I am using ncftpput command instead of $ftp->put command.... But I would appreciate if the same script works on redhat7.2 machine as well.
Thanks lawrence for your effort.....
Tue Jul 4 10:52:43 2006: TonyLawrence
Well, that's simply saying that it can't talk to you. Most likely you have firewall settings stopping it. Check that machines's rules against the Fedora machine.
If you Google "perl ftp illegal port" you'll find a lot of matches..
Don't miss responses! Subscribe to Comments by RSS or by Email
Click here to add your comments
If you want a picture to show with your comment, go get a Gravatar