Eupheus
Eupheus

Reputation: 73

Unable to use Select query while using curl

For my interest. I am trying to use the below curl query:

Delphi$ curl -o /dev/null -s -w %{time_total}  
http://localhost:8080/getquery?db=EmpDt&col=HRDt&query=select * from 
emp where id=1111

but unable to execute it:

[1] 2784
[2] 2785
0.003799invalid option or syntax: 10

[1]-  Done  curl -o /dev/null -s -w %{time_total} 
http://localhost:8080/getquery?db=EmpDt
[2]+  Done col=HRDt

Something is not correct here but not able to get what? Any help would be really helpful. Thanks

Upvotes: 0

Views: 367

Answers (1)

dave_thompson_085
dave_thompson_085

Reputation: 39000

  1. in shell unquoted & terminates command and runs the command to its left in the background; thus your post contains three separate commands run concurrently. Either quote & individually with backslash as \& or surround at least the &s and usually the whole string with either singlequotes'http://host/q?x&y&z' or doublequotes "http://host/q?x&y&z"

    ? and * are also special in shell, although not command terminators, and in general must also be quoted, although in your case after fixing the spaces (below) this becomes less critical

  2. URL cannot contain space; it must be encoded as + (preferred) or %20. Other special characters (here * and =) may not work depending on how your server handles URL parsing, which in turn depends on what your server is and you didn't give any hint; in that case they too must be percent-encoded. (If you want actual +, which you don't, it is encoded as %2B.)

Upvotes: 1

Related Questions