UNIX Shell Interaction

Bell Atlantic apjewell at bigfoot.com
Fri Aug 18 00:35:05 EDT 2000


Ugh - the nemesis!  I've done quite a bit shelling out from Python scripts
and call me stupid, but it's a a real PITA to get a return value that you
want.  The problem is (and hopefully my inadequate response will prompt
someone who actually KNOWS to answer;) - you're SHELLING out to a script
that, itself, starts a shell (in the first place - also might explain why
your environment variables disappear).  In the second place - if the script
doesn't explicitly return a value, even if it WERE to fail - it would most
likely return 0 to Python because the shell ITSELF was successfully launched
and concluded (regardless of the practical conclusion of the script (i.e.,
"(shell): uhhh, I exemacuted and there's no smoke - I must have passed!").
Sooooo. . .  I hope someone else chimes in but for my purposes, I always
write to a file in the Unix script and parse it in the Python script to
determine the true exit conditions.  Would appreciate an update here if you
get a better answer offline!


Andy

Bjorn Pettersen <bjorn at roguewave.com> wrote in message
news:399B0567.B5223207 at roguewave.com...
> try printing the return value...
>
> -b
>
> Stuart Ford wrote:
> >
> > Howdy guys.
> >
> > I'm currently trying to integrate a python script into an existing ksh
> > script.
> >
> > Could anyone tell me how to return a value to the calling script..
> >
> > Example:
> >
> > TEST_VAL=`ValidateData.py $FILENAME`
> >
> >
> > I have tried to assign a value to the variable via os.environ,
> > os.putenv and calling sys.exit,
> > with nothing being assigned!!!  Please help..
> >
> > If they would let me rewrite the shell script in python, i would
> > have... but there are a
> > few people nervous about having to learn python.
> >
> >
> > Thanks in advance!
> > Stuart
>





More information about the Python-list mailing list