V
V
Vitaly Pukhov2015-02-18 09:53:27
linux
Vitaly Pukhov, 2015-02-18 09:53:27

How to understand this strange script?

The "readme" for the application gives a "description" of how you can use the utility in this form:

Here's a typical use case to check 20 seconds from an mp3 file, starting at the 10th second:
echoprint-codegen ./recorded.mp3 10 20 | \
curl -F "[email protected]" developer.echonest.com/api/v4/song/identify?api_ke...
{"response": {"status": {"version": "4.2", "code" : 0, "message": "Success"},
"songs": [{"tag": 0, "score": 66, "title": "Creep", "message": "OK (match type 6)" ,
"artist_id": "ARH6W4X1187B99274F", "artist_name": "Radiohead", "id": "SOPQLBY12A6310E992"}]}}

I'm not a fan of messing around with the console, so I can't understand the syntax of this "instruction", as far as I understand "| \" means something like "pass everything returned by the command on the left to the command on the right" or something like that, but I can't figure out where in this command this is inserted
by curl -F "[email protected]" developer.echonest.com/api/v4/song/identify?api_ke...
purely theoretically instead of "@-", but such crazy syntax "with flowers" seems to me not correct, I ask you to help me figure it out and, if possible, suggest how this can be replaced in C #

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2015-02-18
@Neuroware

echoprint.me/codegen generates something that is passed to curl

-F, --form
(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 RFC
2388. 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 symbol <. 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.
Example, to send your password file to the server, where 'password
' is the name of the form-field to which /etc/passwd will be
the input:
curl -F [email protected]/etc/passwd www.mypasswords. com
To read content from stdin instead of a file, use - as the filename
. This goes for both @ and < constructs.
That's actually all.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question