piping a file to a python script using exec_run
See original GitHub issueUsing the docker python SDK, I’m trying to pipe output of an echo command to exec_run as follows.
container.exec_run(['echo','5','|','python','test.py'])
the test.py has following code
s = input()
print(s)
The output that is produced is :
b'5 | python test.py\n'
I’m trying to mimic the following vanila linux command
echo "5" | python myscript.py
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top Results From Across the Web
Pipe output from shell command to a python script
You need to read from stdin to retrieve the data in the python script e.g. #!/usr/bin/env python import sys def hello(variable): print variable...
Read more >The many ways to pass code to Python from the terminal
The many ways to pass code to Python from the terminal · Via stdin and piping · A string via -c · A...
Read more >Running other programs from Tcl - exec, open
If the first character in the file name argument is a "pipe" symbol ( | ), then open will treat the rest of...
Read more >shell_exec - Manual - PHP
shell_exec — Execute command via shell and return the complete output as a string ... Redirecting the output to a file like this...
Read more >os/exec - Go Packages
The functions Command and LookPath look for a program in the directories listed in the ... Variables; func LookPath(file string) (string, error); type...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try
container.exec_run(['sh', '-c', 'echo 5 | python test.py'])
Thank you dude.