1

I am trying to log my curl output which looks as following: (which are randomly produced every 10th sec)

<RTW>
<RESULT>{ "Result": { "something1": 707,  "something2": { "array": ["95", "51", "65", "33", "95", "109", "87", "37", "49", "86"] } } }</RESULT>
<DISTRICT>{"0000":"City"}</DISTRICT>
</RTW>

My command is as following sh /path/to/script.sh 2>&1 | tee /path/to/logfile.txt

The issue is that I am not logging the original output I am logging some download statistics (which also shows up in the running terminal window). The following things are tracked in the download statistics:

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   249    0   204  100    45    125     27  0:00:01  0:00:01 --:--:--   125
100   249    0   204  100    45     77     17  0:00:02  0:00:02 --:--:--    77

and so on..

How can I log (what I believe is the stdout) from the curl? I have tried changing the number in the 2>&1 section etc.

My curl command inside the script is as following: curl -k --data "objectID=ID&username=username&password=passwd" url -H "Header"

  • You're looking for -o file.txt. You should also consider reading the manual. – Satō Katsura Nov 9 '16 at 16:38
1

You can make curl silent, no progress statistics (and error message will be shown), with the -s (--silent) option:

curl -s ...

From man curl:

-s, --silent

Silent or quiet mode. Don't show progress meter or error messages. Makes Curl mute. It will still output the data you ask for, potentially even to the terminal/stdout unless you redirect it.

  • Just tried that, no output data was shown in the file or in the terminal. – Chess Nov 9 '16 at 16:23
  • @Chess This is the way to silent curl, if no output is being shown you need to look at your script/how you are doing things. – heemayl Nov 9 '16 at 16:25
  • I will not deny that it is, but it is currently not what I was asking for. But thanks :) – Chess Nov 9 '16 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.