1

I can download a file from another server using wget command on a Linux command line, example:

wget ftp_site_name/file_name

But I could not download the same file when I run wget inside a perl script

system "/usr/bin/wget ftp_site_name/file_name";

or

system "wget ftp_site_name";

Here is the snippet of the error message:

Resolving ftp site  ...xx.xx.x.xx

Connecting to ftp site|xx.xx.x.xx|:xx... connected.

Logging in as anonymous ... Logged in!

==> SYST ... done.    ==> PWD ... done.

==> TYPE I ... done.  ==> CWD (1) /pub/??/??/ ...

No such directory `pub/??/??/'.

Any suggestions?

simbabque
  • 53,749
  • 8
  • 73
  • 136
Yacob
  • 515
  • 3
  • 10
  • 18
  • Are those `??` literally in the path you're using, or is that just some anonymization? – Marc B Nov 09 '12 at 14:47
  • 1
    same here : [http://stackoverflow.com/questions/5298198/wget-not-working-properly-inside-a-perl-program][1] [1]: http://stackoverflow.com/questions/5298198/wget-not-working-properly-inside-a-perl-program – willome Nov 09 '12 at 14:48

1 Answers1

0

It is hard to tell what's wrong without the actual error message but I have some guesses:

If the path contains wild chars or spaces use apostrophe or escaping.

my $ftpname="/pub/some path with spaces/works_with_wildchar?/";
my $out = `wget '$ftpname'`;
print "out:\n$out\n";

or
my $ftpname="/pub/some path with spaces/works_with_wildchar?/";
my $out = qx!wget $ftpname!;
print "out:\n$out\n";
user1126070
  • 5,059
  • 1
  • 16
  • 15
  • The exact error message is what I have explained in my first message --2012-11-11 12:49:36-- ftp://server.name/pub/incoming/2009/1000/filename => `filename' Resolving server.name... 20.44.0.16 Connecting to server.name|20.44.0.16|:21... connected. Logging in as anonymous ... Logged in! ==> SYST ... done. ==> PWD ... done. ==> TYPE I ... done. ==> CWD (1) /pub/incoming/2009/1000 ... No such directory `pub/incoming/2009/1000'. – Yacob Nov 11 '12 at 11:53
  • Basically the directory "pub/incoming/2009/1000" does exist but it is unable to find it. – Yacob Nov 11 '12 at 12:00
  • So using "my $out = qx!wget $ftpname!;" did not able to solve my issue. It has the same error message as before as indicated in my previous messages. – Yacob Nov 11 '12 at 12:02