Re: do shell script, redirected piped and backgrounded
Re: do shell script, redirected piped and backgrounded
- Subject: Re: do shell script, redirected piped and backgrounded
- From: Christopher Nebel <email@hidden>
- Date: Sat, 6 Dec 2003 09:13:38 -0800
On Dec 6, 2003, at 8:29 AM, Harald E Brandt wrote:
+--> Randal L. Schwartz wrote 03-12-06:
>>>>> "Harald" == Harald E Brandt <email@hidden> writes:
Harald> do shell script "command 2>&1 | tr '\\n' '\\r' > file_path &"
This is correct from a shell perspective, so if it isn't working from
"do shell script", something is amiss.
Perhaps I should clarify exactly WHAT is not working with expression:
The whole operation is not run in background! Otherwise it works.
Right. If you think about the reasons the "2>&1" is necessary in the
first place, this makes sense. The trick is that "do shell script" is
waiting for the both stdout and stderr to return EOF, so the solution
is to direct them both to some file or device (like /dev/null). If you
look more carefully at your command, you'll notice that only tr's
stdout has been directed anywhere -- stderr is still unmolested, and
"do shell script" will therefore block until tr finishes. In order to
get a pipeline to run in the background under "do shell script", each
stage must have both streams redirected somehow. In this case, you
might use this...
do shell script "command 2>&1 | tr '\\n' '\\r' > file_path 2>&1 &"
or this...
do shell script "command 2>&1 | tr '\\n' '\\r' > file_path 2>
/dev/null &
...since you probably don't want any error output from tr itself.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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.