Search the web
Sign In
New User? Sign Up
a-a-p-dev · A-A-P project development list (closed)
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Question: getting the exit value of a shell command   Message List  
Reply | Forward Message #39 of 43 |
Re: [a-a-p-dev] Question: getting the exit value of a shell command

On Mon, 19 Aug 2002, Bram Moolenaar wrote:

> Steven Knight wrote:
>
> > > The Python documenation says os.system() doesn't return an exit value at
> > > all for MS-Windows 9x. It looks like spawn*() doesn't do the needed
> > > things either. This probably means I need to add some C code to do it
> > > properly... That makes it a lot more difficult to install A-A-P, thus I
> > > certainly hope a Python-only solution can be found.
> >
> > os.spawn*() works fine so long as you pass os.P_WAIT as the first
> > argument, to wait for the exit status of the command.
>
> It looks like os.spawn*() only executes one command, not a shell command
> or pipeline like "cat file | sed expr > tt".

A shell command or pipeline is operating system specific also, if it can't
be done with Python alone, you always have multi platform support problems.

What are the OS-es that need to be supported?

Best regards,

Aschwin Marsman

--
aYniK Software Solutions all You need is Knowledge
Bedrijvenpark Twente 305 NL-7602 KL Almelo - the Netherlands
P.O. box 134 NL-7600 AC Almelo - the Netherlands
telephone: +31 (0)546-581400 fax: +31 (0)546-581401
a.marsman@... http://www.aYniK.com




Mon Aug 19, 2002 6:57 pm

marvinmarsman
Offline Offline
Send Email Send Email

Forward
Message #39 of 43 |
Expand Messages Author Sort by Date

I ran into this issue and can't find a good solution. I hope someone knows the answer to this one. When executing a shell command with ":system", the exit...
Bram Moolenaar
vimboss
Offline Send Email
Aug 19, 2002
10:06 am

... Check google groups (groups.google.com). All solutions there read something like this: { the-command; } 2>&1 ; echo $? > res.tmp | tee /tmp/@... and then...
dionn@...
Send Email
Aug 19, 2002
11:05 am

... Thanks, that was exactly what I needed. The {} need to be placed differently though: { the-command; echo $? > res.tmp; } 2>&1 | tee /tmp/@... -- ...
Bram Moolenaar
vimboss
Offline Send Email
Aug 19, 2002
1:40 pm

... I've only a pointer for you. Hopefully someone will have a better answer, but you should be able to make some creative use of the $? special parameter? ...
Doug Kearns
djkea2@...
Send Email
Aug 19, 2002
11:13 am

Hi Doug, Bram, ... The 2>&1 and $? are only available at WinNT4/2K/XP, Win9x/Me doesnt offer them. The only alernative I know, is using CreateProcess() and...
Thorsten Maerz
torte@...
Send Email
Aug 19, 2002
11:33 am

... The Python documenation says os.system() doesn't return an exit value at all for MS-Windows 9x. It looks like spawn*() doesn't do the needed things...
Bram Moolenaar
vimboss
Offline Send Email
Aug 19, 2002
1:40 pm

... os.spawn*() works fine so long as you pass os.P_WAIT as the first argument, to wait for the exit status of the command. --SK...
Steven Knight
knight@...
Send Email
Aug 19, 2002
2:31 pm

... It looks like os.spawn*() only executes one command, not a shell command or pipeline like "cat file | sed expr > tt". -- If you're sending someone...
Bram Moolenaar
vimboss
Offline Send Email
Aug 19, 2002
6:15 pm

... A shell command or pipeline is operating system specific also, if it can't be done with Python alone, you always have multi platform support problems. What...
Aschwin Marsman - aYn...
marvinmarsman
Offline Send Email
Aug 19, 2002
6:57 pm

... Yep. Since A-A-P needs to execute compilers, linkers and other programs, this is unavoidable. Python doesn't offer platform-independent functions for...
Bram Moolenaar
vimboss
Offline Send Email
Aug 20, 2002
8:29 am

Hi Bram-- ... Here's a solution, from Tom Christiansen's classic "Csh Programming Considered Harmful" article: Consider the pipeline: A | B | C You want to...
Steven Knight
knight@...
Send Email
Aug 19, 2002
12:02 pm

... [...] ... Yes, this currently only works on Unix anyway. I noticed that os.system() always uses "sh", even though "tcsh" is my default shell. That's...
Bram Moolenaar
vimboss
Offline Send Email
Aug 19, 2002
1:41 pm

... You'll need to manipulate file descriptors, either directly using os.dup()/os.fdopen() or through library methods like popen2()/popen3(). In fact, take a...
Steven Knight
knight@...
Send Email
Aug 19, 2002
2:24 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help