On 30Dec2015 21:14, Carlos Barera <carlos.bar...@gmail.com> wrote:
Trying to run a specific command (ibstat) installed in /usr/sbin on an
Ubuntu 15.04 machine, using subprocess.check_output and getting "/bin/sh:
/usr/sbin/ibstat: No such file or directory"
I tried the following:
- running the command providing full path
- running with executable=bash
- running with (['/bin/bash', '-c' , "/usr/sbin/ibstat"])
Nothing worked ...
The first check is to run the command from a shell. Does it work? Does "which
ibstat" confirm that the command exist at that path? Is it even installed?
If it does, you should be able to run it directly without using a shell:
subprocess.call(['/usr/sbin/ibstat'], ...)
or just plain ['ibstat']. Also remember that using "sh -c blah" or "bash -c
blah" is subject to all the same security issues that subprocess' "shell=True"
parameter is, and that it should be avoided without special reason.
Finally, remember to drop the common Linux fetish with "bash". Just use "sh";
on many systems it _is_ bash, but it will provide portable use. The bash is
just a partiular Bourne style shell, not installed everywhere, and rarely of
any special benefit for scripts over the system /bin/sh (which _every_ UNIX
system has).
If none of this solves your problem, please reply including the failing code
and a transcript of the failure output.
Thanks,
Cameron Simpson <c...@zip.com.au>
--
https://mail.python.org/mailman/listinfo/python-list