return a value to shell script

Grant Edwards invalid at invalid
Wed Nov 12 11:03:49 EST 2008


On 2008-11-12, devi thapa <devi.thapa at gmail.com> wrote:

> I am executing a python script in a shell script.  The python
> script actually returns a value. So, can I get the return
> value in a shell script? If yes, then help me out.

There are two ways to "return" something to a shell script.

 1) To return a success/fail indication, use sys.exit(n).  n==0
    means success, n!=0 means fail.

 2) To return the end value of an operation or computation to a
    shell script, you write it to stdout as an ascii string.

-- 
Grant Edwards                   grante             Yow! I'm wet!  I'm wild!
                                  at               
                               visi.com            



More information about the Python-list mailing list