Gossamer Forum
Home : General : Perl Programming :

Problem with wget

Quote Reply
Problem with wget
Hi,

The following works from the command line:

wget http://10.10.10.10/csv/UIC_Export_1.CSV

But it does not work from the following Perl script:

#!/usr/bin/perl

wget http://10.10.10.10/csv/UIC_Export_1.CSV;

I get the message:

Number found where operator expected at wget1.pl line 3, near "//10.10.10.10"
(Missing operator before 10.10.10.10?)
syntax error at wget1.pl line 3, near "wget http:"
Execution of wget1.pl aborted due to compilation errors.

I'm totally new to Perl, and would appreciate any help.

- Ivette
Quote Reply
Re: [Ivette] Problem with wget In reply to
Because you are trying to run a system command in your perl script without telling perl what you are trying to do.

Go to perldoc.com and in the search box on the main page enter "system"
Quote Reply
Re: [Ivette] Problem with wget In reply to
You would need something like this;

Code:
#!/usr/bin/perl

chdir("/path/to/folder/where/you/want/it/saved/");
system("wget http://10.10.10.10/csv/UIC_Export_1.CSV");

print "Content-type: text/html \n\n";
print "Done...";

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] Problem with wget In reply to
Or:

Code:

system("wget http://10.10.10.10/csv/UIC_Export_1.CSV > /path/to/file.CSV");

And make sure you at leaast add in some error checking =)

Last edited by:

Paul: Jun 20, 2003, 6:52 AM
Quote Reply
Re: [Paul] Problem with wget In reply to
Andy & Paul,

Thank you for your help. I'm not a sophisticated programmer (actually not a programmer at all), and appreciate your tips... definitely will take your advice of including some error checking.

I searched for "system" as you suggested, Paul, and found out that I could run a UNIX command in a Perl script by using

system("command");
or

`command`;

Now my little script is working!

- Ivette