Re: Shell script open app. locks script
Re: Shell script open app. locks script
- Subject: Re: Shell script open app. locks script
- From: Christopher Nebel <email@hidden>
- Date: Wed, 26 Feb 2003 12:34:45 -0800
On Wednesday, February 26, 2003, at 04:52 AM, Paul Skinner wrote:
do shell script
"/System/Library/Frameworks/ScreenSaver.framework/Resources/
ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background >
/dev/null 2>&1 &"
Solved this particular issue for me. But here's where I get lost. If
I execute the same code in the terminal I get errors. 'Ambiguous
redirect' and no activation. In AppleScript it does exactly what I
want. ... Why? ... I read the portion of the TN relating to the
differences between 'do shell script' and the terminal. No resolution.
Read the TN again, in particular the part about "which shell does it
use". Unless you've changed your default shell or explicitly run sh,
you're using tcsh in Terminal, which doesn't have the same redirection
syntax as sh, hence the error.
I'd love to get '[1] 1436' back when I execute this do shell script
command.
That's an interesting question. I honestly don't know exactly where
that job id is coming from -- it's not on either of the process's
output streams. I suspect it's an interactive-shell-only thing, which
means you can't get it from d.s.s. directly. What you can do, however,
is exploit a feature of sh. From the man page under Special Parameters:
! Expands to the process ID of the most recent back-
ground command executed from the current shell.
For a pipeline, the process ID is that of the last
command in the pipeline.
So, you can do this:
do shell script
"/System/Library/Frameworks/ScreenSaver.framework/Resources/
ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background >
/dev/null 2>&1 &" & (ASCII character 10) & "echo $!"
...and it'll return the process id of the just-spawned
ScreenSaverEngine. (I should add that to the technote -- that's pretty
useful!) For reasons I don't understand, it gagged on a semicolon
after the initial command, so I used a linefeed instead.
--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.