Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 04-15-2005, 02:05 AM   #1
LQ Newbie
Registered: Jun 2004
Posts: 15

Rep: Reputation: 0
Use pipe with wget

I'm writing a shell script but having difficulties wit the following. I want to use a pipe for wget, however this doesn't seem to work. This is what I try:

$ echo "" | wget
wget: missing URL
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.

Actually I will use another script that return an url instead of the echo command but to keep it simple I thought this should also work. What am I doing wrong? The output of the echo command should be used as input for wget? Yet wget doesn't get any input.

Your help is appreciated.
Old 04-15-2005, 02:38 AM   #2
Senior Member
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Standard input to a program is not the same thing as an argument on the command line. You have two options:
wget $( echo "" )

Or you can use the xargs command:
echo "" | xargs wget
In the first option, everything inside "$( )" is considered a command, and the whole sequence is replaced with the command's output.
Old 04-15-2005, 02:39 AM   #3
LQ Newbie
Registered: Apr 2005
Distribution: Gentoo
Posts: 9

Rep: Reputation: 0
You don't get concept of pipes exactly right. Pipe redirects standard output stream of command to a input stream of another command. Wget in other hand excepts URL as _parameter_, which is not a stream at all.

One way is to use xargs -command to translate:
echo "" |xargs wget

or another example with multiple parameters:
ls | xargs echo

So xargs translates its standard input into its first parameters parameters and executes it.

too slow

Last edited by wilho; 04-15-2005 at 02:40 AM.
Old 04-15-2005, 05:42 AM   #4
LQ Newbie
Registered: Jun 2004
Posts: 15

Original Poster
Rep: Reputation: 0
Thanx guys, I'm glad this is the newbie section. I'm learning


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
regarding mail pipe hinetvenkat Linux - Networking 0 07-16-2005 02:31 AM
2-way pipe saiz66 Programming 3 11-22-2004 07:54 AM
pipe jelly Slackware 2 03-05-2003 03:07 AM
pipe using no pipe soathana Programming 2 02-22-2003 04:33 PM
who with a pipe blown99GT Linux - General 5 07-16-2002 02:58 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:09 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration