Re: Script for Post.Office
Re: Script for Post.Office
- Subject: Re: Script for Post.Office
- From: Christopher Nebel <email@hidden>
- Date: Mon, 8 Mar 2004 12:25:01 -0800
On Mar 8, 2004, at 8:48 AM, Stevan Reese wrote:
Additionally, since Post.Office's parent process is the script, it
will
likely die when it's parent process quits, so killing the script will
probably kill post.office anyway.
I agree that what you are saying makes sense and I expected the same
thing.
But, what I found in my project was that the script was run as the
user and my do shell script "" password passwd with administrator
privileges is a new process as root, not a child process.
How exactly did you determine this? Here's what I saw:
do shell script "sleep 60" with administrator privileges
% ps -axww -opid,ppid,user,command
PID PPID USER COMMAND
1 0 root /sbin/init
198 1 nebel
/System/Library/Frameworks/ApplicationServices.framework/Frameworks/
CoreGraphics.framework/Resources/WindowServer -daemon
10122 198 nebel /Applications/AppleScript/Script
Editor.app/Contents/MacOS/Script Editor -psn_0_18350081
10845 10122 nebel sh -c echo '*****' | sudo -p "" -S sleep 60
10847 10845 root sleep 60
...which is exactly what I'd expect. The command is a child of an sh
process, which is a child of Script Editor. (Which is a child of
WindowServer, which is a child of init, but that's not important here.)
The 'correct' solution (at least as far as 'do shell script' is
concerned)
is to append '&' to the end of the shell process which tells it to
background, returning control to the script while leaving the child
processes running:
do shell script "/usr/local/post.office/post.office &"
Again I agree that this should work. However my experience was that my
script would not proceed until the program I was starting with the
script also was terminated.
That is the correct behavior. Go read TN2065, in particular the
section about backgrounding commands, at
<
http://developer.apple.com/technotes/tn2002/tn2065.html#Section5>.
--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.