PDA

View Full Version : Help with curl command



pkfox
2015-12-06, 09:04
Hi all, I'm trying to run a command against the LMS web server using curl from a linux terminal but am not being successful this is what I've tried



curl -g -X POST -H "Content-Type: application/json" '"{\"id\":1,\"method\":\"slim.request\",\"params\":[null,[\"info total duration ?\"]]}"' http://10.10.1.11:9000/jsonrpc.js


info total duration is a new command Michael added yesterday

DJanGo
2015-12-06, 11:10
Hi all, I'm trying to run a command against the LMS web server using curl from a linux terminal but am not being successful this is what I've tried



curl -g -X POST -H "Content-Type: application/json" '"{\"id\":1,\"method\":\"slim.request\",\"params\":[null,[\"info total duration ?\"]]}"' http://10.10.1.11:9000/jsonrpc.js


info total duration is a new command Michael added yesterday

our curl looks unknown to me...

i dont know why you want to curl the jsonrpc but if you want...
i didn t update to the newest, but that code is running you had to alter the request.


curl 'http://127.0.0.1:9000/jsonrpc.js' --data-binary '{"id":1,"method":"slim.request","params":["",["info","total","songs","?"]]}'

and this should give you only the wanted output.

curl 'http://127.0.0.1:9000/jsonrpc.js' --data-binary '{"id":1,"method":"slim.request","params":["",["info","total","songs","?"]]}'|cut -d '_' -f2- |cut -d ':' -f2|cut -d '}' -f1

Julf
2015-12-06, 13:22
and this should give you only the wanted output.

curl 'http://127.0.0.1:9000/jsonrpc.js' --data-binary '{"id":1,"method":"slim.request","params":["",["info","total","songs","?"]]}'|cut -d '_' -f2- |cut -d ':' -f2|cut -d '}' -f1

Nice! Somebody who still knows how to use UNIX command line tools! I might have used awk... :)

mherger
2015-12-06, 14:22
> Hi all, I'm trying to run a command against the LMS web server using
> curl from a linux terminal but am not being successful this is what I've
> tried

You don't need help with curl, but with the jsonrpc.js implementation
;-). As you might have seen from Jan's response you'll have to separate
the words of your query. Rather than ["info total duration"], you need
to send ["info", "total", "duration"].

Whenever you ask for help, please make sure you include error messages,
results etc. for your actions, too. You didn't mention what your query
returned. And by watching the server.log file you'd probably have seen
that LMS was complaining about an invalid command or similar.


--

Michael

pkfox
2015-12-06, 15:49
> Hi all, I'm trying to run a command against the LMS web server using
> curl from a linux terminal but am not being successful this is what I've
> tried

You don't need help with curl, but with the jsonrpc.js implementation
;-). As you might have seen from Jan's response you'll have to separate
the words of your query. Rather than ["info total duration"], you need
to send ["info", "total", "duration"].

Whenever you ask for help, please make sure you include error messages,
results etc. for your actions, too. You didn't mention what your query
returned. And by watching the server.log file you'd probably have seen
that LMS was complaining about an invalid command or similar.


--

Michael

Apologies, this week has been a steep learning curve for me 😀 - thanks