curl misbehaving


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting curl misbehaving
# 1  
Old 07-24-2012
curl misbehaving

Hi friends,

I have a text file of the following kind

input.txt
Code:
-o abc.pdf  "pdfmyurl.com?url=http://www.abc.com"

I am using this command

Code:
for i in `cat input.txt`; do curl $i; done

It is giving the error

Code:
try 'curl --help' or 'curl --manual' for more information

Any suggestions. I have more than 1000 records in my input.txt
# 2  
Old 07-24-2012
The for-loop is running curl once per word in the file, not once per line. This approach cannot be made to work (at least not without some IFS gymnastics). If you quote the cat command substitution, to prevent the word splitting, the file's entire contents are passed to curl at once.

<dejavu>A while-loop could do it.</dejavu>

Regards,
Alister

Last edited by alister; 07-24-2012 at 11:12 PM..
This User Gave Thanks to alister For This Post:
# 3  
Old 07-24-2012
Quote:
Originally Posted by alister
The for-loop is running curl once per word in the file, not once per line. This approach cannot be made to work (at least not without some IFS gymnastics). If you quote the cat command substitution, to prevent the word splitting, the file's entire contents are passed to curl at once.

<dejavu>A while-loop could do it.</dejavu>

Regards,
Alister
Can u help me with the while loop?

Thanks for your suggestion, though
# 4  
Old 07-24-2012
If each line in the input file has exactly three components, you can probably just use xargs:
Code:
xargs -n3 curl < input.txt

Regards,
Alister
This User Gave Thanks to alister For This Post:
# 5  
Old 07-24-2012
I tried this after googling,

Code:
while read line; do curl $line; done < final.txt

error was

Code:
Couldn't resolve host '"pdfmyurl.com'

I changed my input.txt records to the following

Code:
-o abc.pdf  "http://pdfmyurl.com?url=http://www.abc.com"

and again the different error was

Code:
curl: (1) Protocol "http not supported or disabled in libcurl

Any thoughts?

---------- Post updated at 10:51 PM ---------- Previous update was at 10:50 PM ----------

Quote:
Originally Posted by alister
If each line in the input file has exactly three components, you can probably just use xargs:
Code:
xargs -n3 curl < input.txt

Regards,
Alister
Perfect!!!!!!!!!!!

Awesome!!!!!!!!!!

Great!!!!!!!!!!!

Thanks a lot, Allister. I was working on this for the past 2 hours.

Thanks again.
# 6  
Old 07-25-2012
Quote:
Originally Posted by alister
If each line in the input file has exactly three components, you can probably just use xargs:
Code:
xargs -n3 curl < input.txt

I don't know why I suggested that. If you have one set of curl options and arguments per line, the simplest, most flexible approach is to not hardcode the number of elements and to instead work with each line itself.

Code:
xargs -L1 curl < input.txt

Regards,
Alister
This User Gave Thanks to alister For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. SCO

Curl error

Hello I want to use the Curl and gives me this error. Can someone help me out # curl http : // www .google . es dynamic linker: curl: binder error: symbol not... (3 Replies)
Discussion started by: fersys
3 Replies

2. Shell Programming and Scripting

Help with cURL

Hi all; first of all i need to clarify that i am new to apache2 server configuration and for some needs i want to transfer some files using curl to web directory,so please bear with me: following is the command i m running to transfer file to my web directory: curl -T "q"... (4 Replies)
Discussion started by: arien001
4 Replies

3. UNIX for Dummies Questions & Answers

Basic cURL help!

hi!! this is my first post!! our university student search has this form which uses POST method(the website is swd.bits-goa.ac.in/searchform1)..now i tried sending post data from cURL... curl -o this.html --data "name=rohan&id=&hostel=&room=&branch=&search=Search"... (9 Replies)
Discussion started by: slotlocker
9 Replies

4. Shell Programming and Scripting

Using curl in commandline

Hi, I am using curl to hit a url using http in solaris 10 using commandline, I want to transfer an attachment(using multipart curl -F) also as a part of the request. If anyone has used kindly help me with the syntax. I am using below command: /usr/local/bin/curl -v... (1 Reply)
Discussion started by: manishmaha
1 Replies

5. Shell Programming and Scripting

using curl in a script

Hello everyone I'm currently using a script to upload files (different file names, but same date) to an ftp server (see below) #!/bin/sh # Set the variables HOST=<host> USER=<user> PASSWD=<password> ftp -i -n $HOST <<END_SCRIPT user ${USER} ${PASSWD} mput... (0 Replies)
Discussion started by: soliberus
0 Replies

6. Programming

cURL and cgi

I have a CGI application done in c++ that communicates with PayPal. I've had an issue where the application dies when I try to perform a cURL operation. Upon further inspection it seems that I can run cURL examples from the command line. Upon even further inspection it seems that I can run... (8 Replies)
Discussion started by: tatebn
8 Replies

7. Web Development

Finding which firefox thread is misbehaving

Hello, I am trying to find out how to determine which firefox thread is connected to what site. Using: top -H shows the threads but not what they are connected to. The purpose of this is that some sites run nasty cpu eating programs and trying to figure out which ones. Thanks, mgb (1 Reply)
Discussion started by: mgb
1 Replies

8. Shell Programming and Scripting

use of curl

I have to transfer a file from my aix box to another server using ftps protocol, how can i achieve this using curl preferably or any other utility. Regards Sandeep (0 Replies)
Discussion started by: jayawantsandeep
0 Replies

9. AIX

use of curl

Hi guys , need some help I have to transfer a file from my aix box to another server using ftps protocol, how can i achieve this using curl preferably or any other utility. Thanks Sandeep (0 Replies)
Discussion started by: jayawantsandeep
0 Replies

10. Shell Programming and Scripting

curl

Aren't there any way to download files as below? For example, I want to download all .html files under the root directory of unix.com/ curl -O https://www.unix.com/*.html This won't work, but please tell me the way to do this. Well, the best way is to get the file list of the directory, but i... (6 Replies)
Discussion started by: Euler04
6 Replies
Login or Register to Ask a Question