Re: Returning Values from Bash Scripts



Jorgen Grahn <grahn+nntp@xxxxxxxxxxxxxxxxxxxxxx> writes:
> On Sun, 08 Jan 2006 08:57:01 GMT, Tim Roberts <timr@xxxxxxxxx> wrote:
>> chakkaradeepcc@xxxxxxxxx wrote:
>>>How to execute bash scripts from python (other than using os.popen) and
>>>get the values that those bash scripts return.
>> Why would you eliminate os.popen? It is precisely the right way to do
>> this. That's the same interface bash itself uses to execute scripts.
>> That is, assuming by "values" you mean the stdout from the script. If you
>> really mean the numerical return code, you can use os.system.
> And that's just one "value", of course. And not a very useful one, either --
> it's a non-negative integer, with a pretty low max value -- 255 on my
> machine. Unless you count the crash return codes.

Further, os.system (and os.popen) pass the command through a shell,
and actually gives you the return value from the shell instead of the
command in question. Normally, these are the same thing. But if the
shell fails to execute the command, they aren't - and there's no easy
way to tell that that's what happened.

<mike
--
Mike Meyer <mwm@xxxxxxxxx> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
.



Relevant Pages

  • Re: Redirection issue
    ... 1- execute input commands from standard input, ... the phrase "it does not work anymore" carries very little meaning. ... after compilation and execution of the shell with a simple command like ... all the command in the file are executed as well. ...
    (comp.lang.c)
  • Re: Redirection issue
    ... 1- execute input commands from standard input, ... the phrase "it does not work anymore" carries very little meaning. ... after compilation and execution of the shell with a simple command like ... all the command in the file are executed as well. ...
    (comp.lang.c)
  • Re: shell scripting
    ... and am assuming an sh-compatible shell here.... ... command 1 options arguments ... To run the script, do: ... then you need to use the full path to execute it: ...
    (comp.unix.questions)
  • Re: shell scripting
    ... and am assuming an sh-compatible shell here.... ... command 1 options arguments ... To run the script, do: ... then you need to use the full path to execute it: ...
    (comp.unix.shell)
  • Re: Couple of PC-User Mac noob questions
    ... Writing Bash scripts is pretty straightforward (Bash scripts are to ... I want it to open a shell, execute the command and then close. ... I want to add a custom word to the user agent that I can sniff for in my script and use it to turn on a debug mode in my code. ...
    (comp.sys.mac.misc)