Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #101168

Re: subprocess check_output

From Carlos Barera <carlos.barera@gmail.com>
Newsgroups comp.lang.python
Subject Re: subprocess check_output
Date 2016-01-02 20:39 +0000
Message-ID <mailman.179.1451767167.11925.python-list@python.org> (permalink)
References <CAJYwLU=p_U3V7MfOx3wCH8qkamK0aSHzF1i0g2ZBgTXDgrF03Q@mail.gmail.com> <20151230210227.GA88234@cskk.homeip.net>

Show all headers | View raw


Turns out it wasn't running against the server I thought it was.
Apologies for the spam.

-carlos

On Wed, Dec 30, 2015 at 11:02 PM Cameron Simpson <cs@zip.com.au> wrote:

> On 30Dec2015 21:14, Carlos Barera <carlos.barera@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 <cs@zip.com.au>
>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: subprocess check_output Carlos Barera <carlos.barera@gmail.com> - 2016-01-02 20:39 +0000

csiph-web