0

Currently, I have a script (log.sh) that can pipe content to the REST API of a logging server as follows

curl -H "content-type:text/plain" -d $1 http://my-logging-server.com/api

Running ./log.sh "Hello world" works

But when I try to do a live tail and pipe the results into my shell script:

tail -f live.log | ./log.sh

I get:

curl: no URL specified!

Why doesn't curl recognise a URL?

Hoa
  • 19,858
  • 28
  • 78
  • 107
  • 1
    `tail -f live.log | ./log.sh` doesn't set `$1` in your script. So `curl` sees `http://my-logging-server.com/api` as the argument to `-d` and then no URL argument. – lurker Aug 24 '18 at 10:08
  • to add to @lurker's correct assertion, see https://stackoverflow.com/a/7045517/2186144 for handling $1 or stdin. – roryrjb Aug 24 '18 at 10:15

0 Answers0