Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Didn't try this but...' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Didn't try this but...
Authored by: VEGx on Jan 20, '03 12:15:48PM

Yesterday, we were trying to get this work:
set result to do shell script "/System/Library/Frameworks/ScreenSaver.framework/Resources/ScreenSaverEngine.app/Contents/MacOS/ScreenSaverEngine -background &"

and the script just hangs if you run it in the Script Editor. Which makes me very suspicious about all "&" ending scripts. I have a feeling it's taken away the possibility to run scripts in the background... but then again... I didn't try your script... maybe it works... I'll try it in a sec...



[ Reply to This | # ]
Didn't try this but...
Authored by: macavenger on Jan 20, '03 05:20:37PM

after some experimenting, it looks to me like the key part (to keep the script from hanging) is the '> /dev/null 2>&1 &' If you take this section out, it still works, but the script hangs. Put it back in, and the script exits cleanly. On a related note, the "set results to" section can be shortened to: set results to do shell script "open-x11 /path/to/gimp > /dev/null 2>&1 &"



[ Reply to This | # ]
Didn't try this but...
Authored by: Bernd P. Ziller on Jan 25, '03 08:17:10AM

As you found out, the key part is the redirection of stdout and stderr to /dev/null...

by this you fully detach the background job from shell. if you don't do this, the shell and your backgrounded command still share the same file-handles for stdout and stderr, which makes your script hang.

Sometimes you might even have to redirect stdin with '</dev/null'...

as in 'command >/dev/null 2>&1 </dev/null &'.



[ Reply to This | # ]