Fwd: stderr from 'do shell script': Not always in AS error or redirected as expected
Fwd: stderr from 'do shell script': Not always in AS error or redirected as expected
- Subject: Fwd: stderr from 'do shell script': Not always in AS error or redirected as expected
- From: "Mark J. Reed" <email@hidden>
- Date: Fri, 20 Mar 2009 10:04:28 -0400
Meant to send this to the list.
---------- Forwarded message ----------
From: Mark J. Reed <email@hidden>
Date: Fri, Mar 20, 2009 at 10:03 AM
Subject: Re: stderr from 'do shell script': Not always in AS error or
redirected as expected
To: Jerry Krinock <email@hidden>
On Mon, Mar 16, 2009 at 9:53 PM, Jerry Krinock <email@hidden> wrote:
> After reading TN2065 over many times, and studying about redirects in the
> bash shell, I've concluded that 'do shell script' does not always give
> stderr/stdout where expected.
You seem to be confusing redirects with the behavior of do shell
script. It's simpler to understand if you keep them separate.
The shell sends all its output where you tell it to: stdout, stderr,
some file, whatever. Whether you're using Applescript or not doesn't
change that. This is the portion of the operation where you can
legitimately use the term "redirect".
After "do shell script" finishes executing the shell script, then we
can talk about where the various bits of output wind up. There's no
redirecting at this point.
So once the shell has done its thing, and you can get as fancy as you
want with the redirections inside the shell command, there are only
three possibilities:
1) shell returns zero status. stdout is returned, stderr is discarded:
do shell script "echo this is the return value; echo >&2 this goes nowhere"
2) shell returns nonzero status after sending something to stderr.
stderr is raised as error message, stdout is discarded:
do shell script "echo this goes nowhere; echo >&2 this is raised as an
error; exit 1"
3) shell returns nonzero status without sending anything to stderr.
stdout is raised as error message, and there's nothing to discard:
do shell script "echo this is raised as an error; exit 1"
If the shell script w
do shell script "echo stdout; echo >&2 stderr"
result --> "stdout"
try
do shell script "echo stdout; echo >&2 stderr; exit 1"
on error errMsg
errMsg
end try
--> "stderr"
try
do shell script "echo stdout; exit 1"
on error errMsg
errMsg
end try
--> stdout
try
do shell script "echo stdout; echo
--
Mark J. Reed <email@hidden>
--
Mark J. Reed <email@hidden>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden