Link to home
Start Free TrialLog in
Avatar of jastim
jastim

asked on

Download image from URL

Hi,
How do I download an image from URL (public site) and save it to my local disk in PERL.

ex://www.yahoo.com/file.jpg
Thanks
jasti
ASKER CERTIFIED SOLUTION
Avatar of rj2
rj2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kelly Black
In case you cannot go loading server modules such as a virtual, use this method.

my $lynx = "/path/to/lynx"; # obtain with 'which lynx'
system("$lynx -dump $argv[0] >> $argv[1]");

Use like scriptname.pl http://www.somedomain.com/images/mygif.gif mygif.gif

~K Black
In case you cannot go loading server modules such as a virtual, use this method.

my $lynx = "/path/to/lynx"; # obtain with 'which lynx'
system("$lynx -dump $argv[0] >> $argv[1]");

Use like scriptname.pl http://www.somedomain.com/images/mygif.gif mygif.gif

~K Black
Avatar of SegFault
SegFault

if you have wget, its even easier..

#!/usr/bin/perl

`wget http://www.yahoo.com/file.jpg`;


you can easily execute any shell command in perl by using the back tick operator  (upper left hand corner of the keyboard).

the stdout of the command will be put into any variable you assign.

ie $myvar = `ls`;

will get you all the files/folders in a directory
Nothing has happened on this question in over 7 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
accept answer by rj2.

Please post any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer