LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   curl -K command outputs weird symbols instead of downloading URL from file (https://www.linuxquestions.org/questions/linux-newbie-8/curl-k-command-outputs-weird-symbols-instead-of-downloading-url-from-file-881081/)

meridionaljet 05-16-2011 06:57 PM

curl -K command outputs weird symbols instead of downloading URL from file
 
Hello,

I'm on Ubuntu 11.04. I have read around about how to use curl to download a list of URLs from a text file, and everyone says to use
Code:

curl -K URLlist.txt
. This is what the curl man page says as well. However, for even a simple file with one URL, this command outputs a bunch of weird symbols for me instead of downloading the file.

For example, I have a text file "test.txt" with one line in the following format:

Code:

url = "http://www.example.com/image.jpg"
I use the curl command to download this file:

Code:

curl -K test.txt
...and get something similar to the following output for a long time before the command finally exits:

Code:

��`s:O��n�*n�9 t��jI|y��yt{H�m5;        9/u�Ҭ��W���.�`�D�#�T������̹��'�_�r��䷻�6��;==ѥ��_��Y��k�;        c�v��Y���e��pax��w�?#-+��w��;+���S���=|��        g�%�wد��Q��V��D�gY{#q��.vF�dX�`*,��<�_R���m��z-�z���g$�d����W����~ܸ��_����篍h��O�
No downloaded file shows up after the command is complete. I have no idea why the curl command is not working correctly here. Any help would be appreciated.

teckk 05-16-2011 07:50 PM

Curl is not a download mgr.
The -K switch allows curl to read from a config file.

If you want a download mgr use
wget
gwget
firefox extension
fetch
axle

or a host of others.

You can use curl to see where a file is.
http://linux.die.net/man/1/curl

MTK358 05-16-2011 07:53 PM

Instead of curl, you can use wget. Like this:

Code:

wget -i file-with-urls
The file must simply contain one URL on each line.

meridionaljet 05-16-2011 07:55 PM

Quote:

Originally Posted by teckk (Post 4358317)
Curl is not a download mgr.
The -K switch allows curl to read from a config file.

If you want a download mgr use
wget
gwget
firefox extension
fetch
axle

or a host of others.

You can use curl to see where a file is.
http://linux.die.net/man/1/curl

I know I could use wget, but the idea here was that curl can avoid re-connecting to the FTP server for every single file in a list of URLs, thereby saving a whole ton of time during the download compared to wget, which goes through the trouble of reconnecting for every file. I have easily downloaded lists of images with curl before as well using its sequence option if the URLs are similar, so I know that it is possible, even if that is not its main purpose.

MTK358 05-16-2011 08:00 PM

"curl -K" doesn't create files, it writes the downloaded data to stdout.

The data might have not been text, which explains the funny characters.

TobiSGD 05-16-2011 08:01 PM

You specify an URL, but no output file. So curl writes the downloaded file to the standard output, which will obviously produce weird symbols in case of a JPEG-file.

MTK358 05-16-2011 08:05 PM

I found that curl has the "--remote-name-all" option, which causes it to create files named like the remote files and download to them.

Try this:

Code:

curl --remote-name-all -K URLlist.txt

meridionaljet 05-16-2011 08:13 PM

Quote:

Originally Posted by MTK358 (Post 4358327)
I found that curl has the "--remote-name-all" option, which causes it to create files named like the remote files and download to them.

Try this:

Code:

curl --remote-name-all -K URLlist.txt

Excellent. This is what I was looking for. Thanks a bunch.


All times are GMT -5. The time now is 04:08 PM.