Re: stderr from 'do shell script': Not always in AS error or redirected as expected
Re: stderr from 'do shell script': Not always in AS error or redirected as expected
- Subject: Re: stderr from 'do shell script': Not always in AS error or redirected as expected
- From: Axel Luttgens <email@hidden>
- Date: Tue, 17 Mar 2009 10:42:57 +0100
Le 17 mars 09 à 02:53, Jerry Krinock a écrit :
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. The demo below
illustrates the problem when the command involves gcc (the "C"
compiler).
In one case (Case 4), stderr is not redirected to stdout as it
should be. In another case (Case 5), non-redirected stderr does not
appear in Applescript's try/on error but simply disappears.
[...]
Hello Jerry,
As far as case 4 is concerned, it illustrates a rather old (well, I
think...) behavior of "do shell script": if the shell script ends with
an error without having written anything to stderr, then the error
message is taken from stdout.
Some examples:
try
do shell script "echo 'Hey!' 2>&1; exit 0"
on error errMsg
errMsg
end try
--> "Hey!"
try
do shell script "echo 'Hey!' 2>&1; exit 1"
on error errMsg
errMsg
end try
--> "Hey!"
try
do shell script "echo 'To stderr' >&2; echo 'Hey!' 2>&1; exit 0"
on error errMsg
errMsg
end try
--> "Hey!"
try
do shell script "echo 'To stderr' >&2; echo 'Hey!' 2>&1; exit 1"
on error errMsg
errMsg
end try
--> "To stderr"
Case 5 seems to be another matter: one asks the compiler to emit a
warning, which indeed goes to stderr, but this doesn't raise an error
condition (i.e. 0 return code). Command "do shell script" thus just
returns stdout, on which nothing has been written.
HTH,
Axel
_______________________________________________
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