Gossamer Forum
Home : General : Perl Programming :

Net::FTP not working?

Quote Reply
Net::FTP not working?
Hi. Got a bit of a weird error message being returned by Net::FTP when trying to log in.

Code is;

Code:
# if they want FTP stuff, then transfer it to the FTP site...
if ($remote_ftp) {

print "\n\nFTP'ing to $url...\n\n";

use Net::FTP;
my $_ftp = Net::FTP->new($url, Debug => 1) or &error("Cant FTP. Reason: $!");
$_ftp->login("$user","$pass");
if ($cwd_to) {
$_ftp->cwd($cwd_to);
}
if ($dateorname eq "name") {
$_ftp->put("mysqlbackup.sql.gz");
} else {
$_ftp->put("$date.sql.gz");
}
$_ftp->quit or &error("FTP Upload failed!");
}

...shows;

Quote:
Error: Cant FTP. Reason: No such file or directory

I've even tried hard coding int he URL/user/pass, but I still get this weird error.

Anyone got any ideas? I'm stumped Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Net::FTP not working? In reply to
do you have any open statements earlier in the script that may have failed? the reason i ask is because in Net::FTP's pod is says to use $@ to get the error message.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Net::FTP not working? In reply to
Good catch. $! defaults to No such file or directory on many systems/versions of perl.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [fuzzy logic] Net::FTP not working? In reply to
Voila.. you were right :)

Error: Cant FTP. Reason: Net::FTP: Bad protocol 'tcp'

.. any idea what that means? Unsure Server misconfiguration?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Alex] Net::FTP not working? In reply to
>>>$! defaults to No such file or directory on many systems/versions of perl. <<<

I thought it defaulted to undefined? Or is it the same as $?, where it defaults to '0'?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Net::FTP not working? In reply to
when I use $! to try to get an error on Net::FTP I get "invalid argument".

Code:
use Net::FTP;

open (FOO, "<bar.txt") or warn $!;

Net::FTP->new("foo.perlmad.com") or warn $!;

print "hello";

but when I use $@, I get the error "bad hostname: 'foo.perlmad.com'" that I would expect:

Code:
use Net::FTP;

open (FOO, "<bar.txt") or warn $!;

Net::FTP->new("foo.perlmad.com") or warn $@;

print "hello";

This is on WinXP Home, Perl 5.8.0 MSWin32-x86-multi-thread build 806.

Philip
------------------
Limecat is not pleased.
Quote Reply
Re: [fuzzy logic] Net::FTP not working? In reply to
Yeah. Any ideas on the tcp error though? I've tried;

linkssql.net
www.linkssql.net
http://www.linkssql.net (which I didn't expect to work anyway)

TIA.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Net::FTP not working? In reply to
Second hit on google reveals:

http://www.mail-archive.com/...rl.org/msg04141.html

Sounds like a server issue. Does the server have an entry for tcp:

[root@east root]# cat /etc/protocols | grep tcp
tcp 6 TCP # transmission control protocol
[root@east root]#

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] Net::FTP not working? In reply to
Damn. Can I get access to this command on a shared server? The weird thing is that it works fine on my admin area (I setup a subdomain where I can upload copies of LSQL to clients sites without having to do it allon dialup).... Unsure

BTW, this isn't on my dedicated server... I've still got to move the site over :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Net::FTP not working? In reply to
You should be able to view the /etc/protocols file without any special root privileges, yes.

What's the error you're getting? Permission denied?

- wil
Quote Reply
Re: [Wil] Net::FTP not working? In reply to
Ok, I'll run that command in a second to see what it shows.


>>>What's the error you're getting? Permission denied? <<<

Error: Cant FTP. Reason: Net::FTP: Bad protocol 'tcp' , or are you refering to the error I get when running that command? I havn't tried it yet.... just catching up on emails :p

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Net::FTP not working? In reply to
I'm referring to the error you're getting, if any, when viewing that file? I assumed you had and you ran into errors when you asked the question 'does that work on a shared hosting provider?'.

- wil
Quote Reply
Re: [Wil] Net::FTP not working? In reply to
jailshell-2.05a$ cat /etc/protocols | grep tcp
cat: /etc/protocols: No such file or directory
jailshell-2.05a$

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Net::FTP not working? In reply to
What does /etc/issue and 'uname' tell you?

- wil
Quote Reply
Re: [Wil] Net::FTP not working? In reply to
jailshell-2.05a$ /etc/issue
jailshell: /etc/issue: No such file or directory
jailshell-2.05a$ uname
Linux
jailshell-2.05a$

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Net::FTP not working? In reply to
Hm.

Try:

Code:
perl -le 'print getprotobyname("tcp")'

You can also try 'ypcat -x' to see if any files are imported over NIS.

- wil

Last edited by:

Wil: Sep 4, 2003, 2:37 AM
Quote Reply
Re: [Wil] Net::FTP not working? In reply to
jailshell-2.05a$ perl -le 'print getprotobyname("tcp")'

jailshell-2.05a$


Thanks for your help so far :)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Net::FTP not working? In reply to
Code:
memphis% perl -le 'print getprotobyname("tcp")'
tcpTCP6
memphis%

Hm. Net::FTP reqires getprotobyname to work correctly.

- wil
Quote Reply
Re: [Wil] Net::FTP not working? In reply to
I'll send an email to my host, and get them to check it out. I need this working for development on my Auto_Backup plugin. At least its not my code that was wrong (or me going mad Crazy)

Thanks for your help.

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Net::FTP not working? In reply to
Yeah, probably best. I can help you so far to diagnose but I can't do much to fix it, sorry.

- wil
Quote Reply
Re: [Wil] Net::FTP not working? In reply to
Ok, got it working on my servers with GT. Something I have noticed though, is that the file sizes seem to be different;

-rw-r--r-- 1 656 linkssql 10756375 Sep 4 08:41 mysqlbackup.sql.gz

.. and...

-rw-r--r-- 1 linkssql linkssql 10798590 Sep 4 12:41 mysqlbackup.sql.gz

Notice the file sizes are different by a little bit. Is this anything major, or just a problem where the script isn't doing something right?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!