Using wget in a Perl script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using wget in a Perl script
# 1  
Old 01-16-2009
Using wget in a Perl script

Hi,
I've written a script in Perl that generates a URL and prints it. So if I run the script from the command line, I get something like this:
Code:
$ script.pl
http://www.url.com/folder/file.ext

I would like to use this script with wget to download the file at the URL generated. Is there a simple way to redirect the output of a perl script to wget so that I can download the file using the script?

I couldn't think of any way to do this, so my thought was to output the URL to a file, then write a shell script to read the contents of the file and call wget with the correct URL, but this seems like an unnecessarily complicated solution. Is there an easy way to call wget from a Perl script?

Thanks for any help!
# 2  
Old 01-16-2009
Thats easy! Just use either backticks or.. var substitution.. such as..

Code:
test=$(perl -e "print 'Hi hi hi hi';");echo $test;

or...

Code:
echo `perl -e "print 'Hello World';"`

So you could easily do..

Code:
wget `perl script.pl`

Have fun!
# 3  
Old 01-16-2009
Thanks!

Thanks! I knew there had to be an easy way... Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Homework & Coursework Questions

Loop Script with wget until exit is typed

Morning all, I am attempting to complete the below script which will do the following (skip the ping part) using Bash. Prompts the user to type in a URL to download, or to type exit to exit the script. If a URL is typed, wget to download the webpage and then loop back to prompting for a... (2 Replies)
Discussion started by: Jgerds1990
2 Replies

2. Shell Programming and Scripting

Wget - working in browser but cannot download from wget

Hi, I need to download a zip file from my the below US govt link. https://www.sam.gov/SAMPortal/extractfiledownload?role=WW&version=SAM&filename=SAM_PUBLIC_MONTHLY_20160207.ZIP I only have wget utility installed on the server. When I use the below command, I am getting error 403... (2 Replies)
Discussion started by: Prasannag87
2 Replies

3. Shell Programming and Scripting

Formatting wget request within script

When using a browser and calling this url .. the data returns the proper range of information ichart dot finance dot yahoo dot com/table.csv?s=YAHOO&a=3&b=14&c=2012&d=03&e=20&f=2012&g=d&ignore.csv (geeze wont let me post url's sorry ) However in my script the formatting is messing up on... (4 Replies)
Discussion started by: harte
4 Replies

4. Shell Programming and Scripting

How to download to a file using wget in perl?

Hi, I want to download some online data using wget command and write the contents to a file. For example this is the URL i want to download and store it in a file called "results.txt". #This is the URL. $url="http://www.example.com"; #retrieve data and store in a file results.txt ... (3 Replies)
Discussion started by: vanitham
3 Replies

5. Shell Programming and Scripting

wget won't from script

I am trying to use wget to capture a web page on the Internet. If I use the command from a terminal like: wget Whidbey Island, Naval Air Station WA Weather -O /tmp/FIL.tmp it works but if I use it in a bash script the size of /tmp/FIL.tmp is zero. Can someone help me. Should I not be using... (5 Replies)
Discussion started by: slak0
5 Replies

6. UNIX for Dummies Questions & Answers

wget --dns-timeout script

#!/bin/sh # 'clear' for i in $(seq -w 15 37); do echo $i wget --dns-timeout=0.0001 http://napdweb${i}.eao.abn-iad.ea.com:8000/webcore/test/test.jsp -o 1 A=`cat 1` C=$(expr "$A" :... (1 Reply)
Discussion started by: veerumahanthi41
1 Replies

7. Shell Programming and Scripting

help with wget script.

#!/bin/sh # 'clear' for i in $(seq -w 15 37) do echo $i echo The content in Z Z=`wget --dns-timeout=0.001 http://napdweb${i}.eao.abn-iad.ea.com:8000/webcore/test/test.jsp` echo $Z A="Connection timed out." echo The content in A echo $A expr "$A" : '..\(...\)' echo $A done ... (3 Replies)
Discussion started by: veerumahanthi41
3 Replies

8. Shell Programming and Scripting

How to script wget in bash?

The script below is giving me grief! The error message says /download.bash: line 16: syntax error near unexpected token `else' ./download.bash: line 16: `else wget "http://downloads.sourceforge.net/hibernate/hibernate-3.2.5.ga.zip?modtime=1185893922&big_mirror=1" ' I think it must be a... (1 Reply)
Discussion started by: siegfried
1 Replies

9. Shell Programming and Scripting

Script to download file using wget

Hi I need a Shell script that will download a text file every second from a http server using wget. Can anyone provide me any pointers or sample scripts that will help me go about this task ??? regards techie (1 Reply)
Discussion started by: techie82
1 Replies

10. UNIX for Advanced & Expert Users

Wget call in a Perl script

I've got to do a wget call in a Perl Script. I am basically doing migration of a shell script which was previously doing it. The code in the sh file was as follows. wget -nv -o /tmp/wget.run.log -t 5 -w 10 http://windows-server/myapp/1try.asp?myparam=no This wget command is executing an... (1 Reply)
Discussion started by: rahulrathod
1 Replies
Login or Register to Ask a Question