Re: shell return values
"Lars Ivar Igesund" <[email protected]>
| Newsgroups | gmane.comp.tools.aap.devel |
|---|---|
| Message-ID | <01af01c39d4c$c5f61520$0200000a@mesmer> |
Hmm, consider this code from Util.py; logged_system(). This shows
that the return value from os.system() is dealt with also on winxp.
In my case it returns 1. I see no reason why that should mean that
an error happened. My program runs flawlessly (at least for the test
in question), using D's printf (really the C printf) for the output.
try:
if os.name == "posix":
res = os.system(newcmd)
else:
# system() on MS-Windows can handle only one command at a time
and
# must not end in a NL. Do the same on other non-Unix systems
for
# now.
# TODO: system() isn't available on the Mac
# TODO: system() always returns zero for Windows 9x
for line in string.split(newcmd, '\n'):
if line: # skip empty lines
res = os.system(line)
if res:
break
except KeyboardInterrupt:
msg_info(recdict, _("Interrupted"))
res = 1
----- Original Message -----
From: "Bram Moolenaar" <[email protected]>
To: "Lars Ivar Igesund" <[email protected]>
Cc: <[email protected]>
Sent: Tuesday, October 28, 2003 12:56 PM
Subject: Re: [A-A-P-develop] shell return values
>
> Lars Ivar Igesund wrote:
>
> > I've made a small app that want to call through :sys
> > AAP then bails out because the shell returned 1.
> > I'm on Winxp, using cmd.exe. I don't understand why
> > the return value of 1 means that there is something
> > wrong. Where can I find documentation on the return
> > values of the shell? I've looked through msdn, but
> > couldn't find any specific values. I guess you must
> > have found something since only the return value
> > of 0 is accepted.
>
> This is a Unix thing: an exit value zero means OK, a non-zero value
> indicates a problem.
>
> In case you need to ignore the value you can do:
>
> @try:
> :sys your-command-here
> @except:
> :print Warning: your-command-here returned non-zero
>
> --
> [SIR LAUNCELOT runs back up the stairs, grabs a rope
> of the wall and swings out over the heads of the CROWD in a
> swashbuckling manner towards a large window. He stops just short
> of the window and is left swing pathetically back and forth.]
> LAUNCELOT: Excuse me ... could somebody give me a push ...
> "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES
LTD
>
> /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net
\\\
> /// Creator of Vim - Vi IMproved -- http://www.Vim.org
\\\
> \\\ Project leader for A-A-P -- http://www.A-A-P.org
///
> \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html
///
>
-------------------------------------------------------
This SF.net email is sponsored by: The SF.net Donation Program.
Do you like what SourceForge.net is doing for the Open
Source Community? Make a contribution, and help us add new
features and functionality. Click here: http://sourceforge.net/donate/