Posts

Showing posts with the label pipe

Is it possible to upload a file with cURL from a pipe?

Is it possible to upload a file with cURL from a pipe? I mean POSTing a standard file upload form. Usual command line contains this switch in this case: -F "Filedata=@filename.zip" However when I try to feed a named pipe made by linux command "mkfifo", eg. "mkfifo filename.zip", I always get an error message on the producer side: curl: (23) Failed writing body (1856 != 16384) And also some error message appears at consumer side of the fifo. I fed my fifo with another curl command on producer side, eg.: curl http://example.com/archive.zip > filename.zip And on consumer side: curl http://example.com/fileupload.php -F "file=@filename.zip" When I pass a Content-Length HTTP header at the consumer side of my fifo, I don't get error message at the producer side, but error message still appears at the consumer (uploading) side, unsuccessful upload. curl http://example.com/fileupload.php -F "file=@filename.zip" -H "Content-Length: ...

python shell command pipes grep no results

python shell command pipes grep no results I am trying to get a domain name from a cpanel user in python. Here is my code: import subprocess user = "testuser" getuserdata = 'cat /var/cpanel/users/' + user getdnsline = 'grep "DNS="' test = 'wc -l' userdataprocess = subprocess.Popen(getuserdata.split(), stdout=subprocess.PIPE) testprocess = subprocess.Popen(test.split(), stdin=userdataprocess.stdout, stdout=subprocess.PIPE) test, error = testprocess.communicate() print(test) dnslineprocess = subprocess.Popen(getdnsline.split(), stdin=userdataprocess.stdout, stdout=subprocess.PIPE) website, error = dnslineprocess.communicate() print(website.decode('utf-8').splitlines()) my output is: b'60n' So this means, that the wc -l command gives back 60 lines. So passing the output of the first getuserdata command to the wc -l command works. However, the grep command always return blank. No matter it I put in "DNS=" or "=...