Every time I try to invoke a command that does not exist ($ a
, for example) in the console (/bin/bash) the interpreter waits for a long time. And when I interrupt it (^C), I get a error message from Python interpreter. Instead of that, I expect it to tell me that the command was unrecognized. Why is this happening?
$ a
^C
Traceback (most recent call last):
File "/usr/lib/python2.7/encodings/__init__.py", line 32, in <module>
root@dell:/home/antonio/workspace/biz_index# from encodings import aliases
File "/usr/lib/python2.7/encodings/aliases.py", line 17, in <module>
"""
KeyboardInterrupt
^C
Execute an existing bash script using Python subprocess module. We can also execute an existing a bash script using Python subprocess module.
Running shell commands: the shell=True argument Both with check_output() and communicate() you have to wait until the process is done, with poll() you're getting output as it comes.
To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World!
Are you on an ubuntu machine? Ubuntu has a command-not-found package which is implemented in python, you may have interrupted that.
In your path, there may be a script with the same name as one called by the command-not-found
package. If there is, this script is likely the one doing the hanging. To print your path in a readable way, run echo $PATH | tr -s ':' '\n'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With