0

I'm not famililar with the shell but i have to run this command from a Python file:

curl -XDELETE 'localhost:9200/event/_query?pretty' -d '{"query" : { "range" : { "int_timestamp" : { "lte" : "2016-06-09 08:55:10" } } } }'

From the file i use os.popen to execute the command. I have tried it also with os.system. In both cases it gives me the following Error:

(23) Failed writing body

But when i run this command in the shell, it worked perfect.

What did i wrong? Thanks for help!

EDIT: I don't know why because i doesn't change something. But now it worked with os.system instead of os.popen.

Anyway thanks for help!

Melody
  • 182
  • 2
  • 12
  • 2
    Can you show us your python attempt ? Anyway you have good information about the error here http://stackoverflow.com/questions/16703647/why-curl-return-and-error-23-failed-writing-body – Diane M Jun 09 '16 at 07:13
  • In my python file i use this command: `os.popen('curl -XDELETE \'localhost:9200/event/_query?pretty\' -d \'{"query" : { "range" : { "int_timestamp" : { "lte" : "'+stdate+'" } } } }\'')` – Melody Jun 09 '16 at 07:27

1 Answers1

0

The error (23) Failed writing body indicates you didn't properly wait for curl to output its data before closing the file descriptor. This can be caused by not calling read() after os.popen()

os.system can do the trick, but it doesn't seem like you can retrieve its standard output.

Diane M
  • 1,503
  • 1
  • 12
  • 23