Re: Script for Post.Office
Re: Script for Post.Office
- Subject: Re: Script for Post.Office
- From: Andrew Oliver <email@hidden>
- Date: Sun, 07 Mar 2004 19:38:52 -0800
Umm... No. The first process won't finish, so the second one still won't get
run.
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.
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 &"
However, I still maintain the correct method of doing this is via a normal
startup script in /System/Library/StartupItems, and controlled via the
normal /etc/hostconfig file.
There are many reasons for taking this approach, not least is the ability to
define dependencies (e.g. don't start Post.Office unless the network is up).
I'm astounded that Post.Office doesn't come with a pre-installed script just
for this purpose.
Andrew
:)
On 3/7/04 6:26 PM, "Stevan Reese" <email@hidden> wrote:
>
Your AppleScript will stay open and running as long as the processes
>
that are called by the script are still active.
>
What you need to do is kill the Applescript program after it has done
>
it's job.
>
There maybe a better way but the following is something that works but
>
not from the editor.
>
>
global PID -- making this global is only necessary if you are using the
>
variable in subroutines or more than one tell application...
>
global killme
>
global passwd
>
set passwd to "userpassword"
>
set myname to "myfilename.app"
>
set PID to do shell script "ps -ax|grep " & myname -- this lists the
>
processes with myfilename in them, there will be 3, the applescript,
>
the shell running the command and the grep.
>
--display dialog PID
>
set killme to word 1 of PID
>
-- your script
>
do shell script "/usr/local/post.office/post.office; kill -9 " & killme
>
password passwd with administrator privileges
>
The ";" tells the shell to do the first thing then the next thing. Kill
>
-9 PID terminates the process with no questions or other options.
>
>
BTW
>
password passwd with administrator privileges inserts a sudo in front
>
of your command string
>
>
stevan
>
>
On Mar 7, 2004, at 1:21 PM, George Priggen wrote:
>
>
> Gnarlie or anyone
>
>
>
> I took your suggestions and added something else to handle the password
>
> issue because it kept asking for the password. The result:
>
>
>
> do shell script "sudo /usr/local/post.office/post.office" password
>
> "userpassword" with administrator privileges
>
>
>
> It works and opens up Post.Office on startup just like we want it to.
>
> The
>
> only problem when testing it out in the Script Editor and also as an
>
> application is the dreaded color ball keeps spinning. And no when I
>
> saved
>
> it I did not check "Stay open".
>
>
>
> What are your suggestions for getting the ball to stop and the
>
> application
>
> to close?
>
>
>
> Looks like we are getting close.
>
>
>
> George
>
>
>
>> From: Gnarlodious <email@hidden>
>
>> Date: Sun, 07 Mar 2004 13:00:09 -0700
>
>> To: Applescript <email@hidden>
>
>> Subject: Re: Script for Post.Office
>
>>
>
>> Entity George Priggen spoke thus:
>
>>
>
>>>> do shell script "sudo /usr/local/post.office/post.office"
>
>>> 1. Do I just save this command in a text file and put it into the
>
>>> startup
>
>>> items folder?
>
>> As an Applescript, you will paste it into the Script Editor. Ensure
>
>> it runs
>
>> and does what you want. Then select "Save As" and save as
>
>> "Application".
>
>> Script Editor may have an option to deselect "show startup dialog,
>
>> I'm not
>
>> sure, but you should choose not to show the startup window.
>
>>
>
>> Put the script wherever you want, probably ~User/LibraryScripts/
>
>> If no such folder exists you can create it. When the script is in
>
>> place open
>
>> your "Accounts" prefpanel and select your name, then "Startup Items"
>
>> in the
>
>> upper right corner. Now click "+" to add an item and navigate to the
>
>> script,
>
>> or just drop it in the box.
>
>>
>
>>> 2. Do I make this into a command file by adding ".command" to it and
>
>>> then
>
>>> put it into the startup items folder.
>
>> Not recommended considering your level of expertise. Besides, I'm not
>
>> sure
>
>> *.command files work anymore in Panther.
>
>>
>
>>> 3. Do I need to do anything with chmod or passwords?
>
>> As above. If you want to create an actual UNIX StartupItem I'll walk
>
>> you
>
>> through it, but the AS solution should get you going.
>
>> If the AS asks for a password every reboot the UNIX solution might be
>
>> best.
>
>>
>
>> -- Gnarlie's Applescript page
>
>> http://www.Gnarlodious.com/OSX/AppleScript/AppleScript.html
>
>> _______________________________________________
>
>> 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.
>
> _______________________________________________
>
> 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.
>
_______________________________________________
>
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.
_______________________________________________
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.