Need help with command line curl

Sphexi

Diamond Member
Feb 22, 2005
7,280
0
0
I'm honestly not familiar too much with using curl at all, but I'm stuck trying to troubleshoot this for a pretty big client of ours. Essentially they're trying to use curl on their SunOS based system to access an API of ours, which lets them upload a file with EFT transactions in it to run.

What seems to be happening is that everything after the first variable in the string is being truncated, we've verified this by altering the order of the variables and getting back different errors based on what actually got submitted. The string itself works fine when pasted into IE and submitted, so it has to be on their end. This is what they have so far:

bash-2.05$ /usr/local/bin/curl -s -S -k -m 7 https://www.xxxx.com/scripts/b...022&serviceVersion=1.1
[1] 15668
[2] 15669
[3] 15670
[4] 15671
[2] Done loginUser=xxxx
[3]- Done loginPass=xxxx
[4]+ Done processDate=xxxx
bash-2.05$ <?xml version="1.0" encoding="ISO-8859-1"?>
<response>
<code>3</code>
<message>Service version not supported.</message>
<batch_id>0</batch_id>
</response>

[1]+ Done /usr/local/bin/curl -s -S -k -m 7 https://www.xxxx.com/scripts/b....asp?loginCompany=xxxx


I know it's just a server log, but I"m thinking there's some special option they have to use, like -d, that tells curl to emulate a standard HTTP POST or something, instead of what it's doing now. Any ideas, or any other info needed to help?

Thanks!
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
An & in bash tells it to background the task, so every time it sees a & it things that's a separate command. Honestly if they know anything about unix shells they should know this, it's pretty worrysome that they don't.

Just quote the string with single quotes and bash will pass it on literally instead of parsing it, like /usr/local/bin/curl -s -S -k -m 7 'https://www.xxxx.com/scripts/b...022&serviceVersion=1.1'.
 

Sphexi

Diamond Member
Feb 22, 2005
7,280
0
0
Sounds logical enough. I think the guy figured it out, at least he said he did, he didn't tell me how though :(...the next problem we had is that this process is also supposed to upload a file to our system. Our recommended usage is to create a HTML form, with a "file" input type, and to let the browser do the work. I have zero clue how they emulated that process, but he managed to get a file uploaded so I guess he did.

This is the crappy part of my job, trying to figure out something I have no training or experience in, for a client who should know how to do this already. But then again, we'll make enough money off them to pay for my salary plus one of my co-workers, so I was given the order to make sure they integrated properly :)
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
curl can do POSTs and emulate form submission too so there's any number of ways they could've done it.

-d/--data <data>
(HTTP) Sends the specified data in a POST request to the HTTP server, in the same way that a browser does when a user has filled
in an HTML form and presses the submit button. This will cause curl to pass the data to the server using the content-type applica-
tion/x-www-form-urlencoded. Compare to -F/--form.
...
-F/--form <name=content>
(HTTP) This lets curl emulate a filled in form in which a user has pressed the submit button. This causes curl to POST data using
the Content-Type multipart/form-data according to RFC1867. This enables uploading of binary files etc. To force the ?content? part
to be a file, prefix the file name with an @ sign. To just get the content part from a file, prefix the file name with the letter
<. The difference between @ and < is then that @ makes a file get attached in the post as a file upload, while the < makes a text
field and just get the contents for that text field from a file.