Re: To err on the exit code of the FIRST cmd of a piped do shell script
Re: To err on the exit code of the FIRST cmd of a piped do shell script
- Subject: Re: To err on the exit code of the FIRST cmd of a piped do shell script
- From: Deivy Petrescu <email@hidden>
- Date: Mon, 8 Dec 2003 10:17:02 -0500
At 3:26 PM +0100 12/8/03, Harald E Brandt wrote:
Consider this toy example:
do shell script "curl badURL | vis"
Without the pipe, the thing would error with
error code 6 - very easy to trap with a try
block. With the pipe, however, it does not error
at all! That's because the exit status is the
exit status of the last command specified in the
pipeline - basic shell behavior. But of course I
want that line to error since curl is erroring.
How to do that?
In principle, I could redirect (or actually
duplicate) stderr to stdout and parse the
result. That's a drag, since stderr from curl
will always output lots of progress text also in
normal situations, and in this particular case I
do not want that text - I just want it to error
with the exit code for curl if it has problems.
Another alternative is to redirect stderr from
curl to a file and then read and parse that. But
there's got to be a smarter way!?
A third way is to redirect stdout from curl to a
file, then connect the command with '&&' to a
command that reads the file and then deletes it.
The '&&' would make the expression to error on
the first failing command, i.e the curl command.
But is there a smarter way to do this that
doesn't need to store the result temporarily on
disk?
--heb
Did you try the -f option with curl ?
--
Regards
Saudagues
Deivy
http://www.dicas.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.