Welcome to MacBoardz.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

startup script

 
   Macintosh computer (Home) -> Apple Scripts RSS
Next:  Outgoing accounts  
Author Message
anni

External


Since: Oct 13, 2008
Posts: 10



(Msg. 1) Posted: Wed Nov 26, 2008 1:06 am
Post subject: startup script
Archived from groups: alt>comp>lang>applescript (more info?)

hi,

i want to create script which contineously run in background. It
started automatically when system is started. When any error will
occur script restarted itself again.

how could i do that. any idea...

lets say i want to log, application name and time when it is started.

 >> Stay informed about: startup script 
Back to top
Login to vote
Jo_y

External


Since: Jun 22, 2008
Posts: 36



(Msg. 2) Posted: Wed Nov 26, 2008 2:04 am
Post subject: Re: startup script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

First, write your script, insert this into an idle -loop and then save
your script as stand -open application, at least, go in the account
preference panel of your system and add it to the applications list,
from where it will be called at startup together with the other items
in this list.
The script cannot restart itself after a crash, because this requires
another application module, which can crash too. (the known "Demons",
where runs in backround are written in a better code as the simple
applescript. Try to use Xcode, this works.)

 >> Stay informed about: startup script 
Back to top
Login to vote
anni

External


Since: Oct 13, 2008
Posts: 10



(Msg. 3) Posted: Wed Nov 26, 2008 2:21 am
Post subject: Re: startup script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Nov 26, 3:04 pm, Jo_y wrote:
> First, write your script, insert this into an idle -loop and then save
> your script as stand -open application, at least, go in the account
> preference panel of your system and add it to the applications list,
> from where it will be called at startup together with the other items
> in this list.
> The script cannot restart itself after a crash, because this requires
> another application module, which can crash too. (the known "Demons",
> where runs in backround are written in a better code as the simple
> applescript. Try to use Xcode, this works.)

hi joy,

thanx for reply,
could you check this... is it right

[applescript]
repeat while 1 = 1
idle
--return "hi"
end repeat

on idle
display dialog "hello, hw r u"
delay 5
end idle
[/applescript]

regards,
anni
 >> Stay informed about: startup script 
Back to top
Login to vote
Donald Hall

External


Since: Jul 10, 2003
Posts: 91



(Msg. 4) Posted: Wed Nov 26, 2008 9:26 pm
Post subject: Re: startup script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
,
anni wrote:

> On Nov 26, 3:04 pm, Jo_y wrote:
> > First, write your script, insert this into an idle -loop and then save
> > your script as stand -open application, at least, go in the account
> > preference panel of your system and add it to the applications list,
> > from where it will be called at startup together with the other items
> > in this list.
> > The script cannot restart itself after a crash, because this requires
> > another application module, which can crash too. (the known "Demons",
> > where runs in backround are written in a better code as the simple
> > applescript. Try to use Xcode, this works.)
>
> hi joy,
>
> thanx for reply,
> could you check this... is it right
>
> [applescript]
> repeat while 1 = 1
> idle
> --return "hi"
> end repeat
>
> on idle
> display dialog "hello, hw r u"
> delay 5
> end idle
> [/applescript]
>
> regards,
> anni

You are not using idle correctly. Try this:

on idle
display dialog "hello, hw r u"
return 5
end idle

Compile and save this script as a stay-open application. It will display
your dialog every 5 seconds until you Quit the program.

Nothing else is needed.

There is no easy way in AppleScript to be notified when an application
starts. The closest thing you can do is to check the names of all
running programs in your idle handler and try to determine if any new
programs have started since the idle handler last ran.

HTH,

Don

--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
http://www.appsandmore.com
don at appsandmore dot com
"Schedule your scripts with Script Timer"
 >> Stay informed about: startup script 
Back to top
Login to vote
Sander Tekelenburg

External


Since: Nov 07, 2003
Posts: 648



(Msg. 5) Posted: Thu Nov 27, 2008 10:25 pm
Post subject: Re: startup script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article
,
anni wrote:

> i want to create script which contineously run in background. It
> started automatically when system is started.

If you mean what you say:
<http://developer.apple.com/macosx/launchd.html>. launchd is the
background process that starts the others. One Ring to Rule Them All.

If instead you mean "when the user logs in", you could use a stay-open
applet with an on idle handler.

> When any error will
> occur script restarted itself again.

Nothing can start itself. To achieve such behaviour, you'll need
something *else* to monitor it, and to act when appropriate. Here too
launchd is probably a good choice. Or cron. Or a second AS applet.
Depends on what you're comfortable with, what level of reliability you
want to achieve, etc.

--
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>

Mac user: "Macs only have 40 viruses, tops!"
PC user: "SEE! Not even the virus writers support Macs!"
 >> Stay informed about: startup script 
Back to top
Login to vote
Simon Slavin1

External


Since: May 16, 2004
Posts: 543



(Msg. 6) Posted: Fri Nov 28, 2008 6:26 pm
Post subject: Re: startup script [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 26/11/2008, anni wrote in message <33903372-fa7f-4f31-816d-
80b48cbf099c DeleteThis @r10g2000prf.googlegroups.com>:

> [applescript]
> repeat while 1 =3D 1
> idle
> --return "hi"
> end repeat
>
> on idle
> display dialog "hello, hw r u"
> delay 5
> end idle
> [/applescript]

Read the documentation for the 'idle' handler before using it. Also, read
a newsgroup before posting to it.

Basically, replace all of that with

on idle
display dialog "hello, hw r u"
return 5
end idle

Save the script with the 'stay open' box checked.

Simon.
--
http://www.hearsay.demon.co.uk
 >> Stay informed about: startup script 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
Running a script at startup without having to press run... - I solved the issue of the script not running but I was just wondering... is their a way of running a script automatically at startup without having to press the run button and for that mater without having the applescript scripting window launch??? ..

Script editor crashing on startup w/address error - This one has me stumped. Running OS9.2.2, Script Editor 1.8.3, G4 (Titanium). I've tried starting up with extensions turned off... Tried dumping the preferences... Tried reinstalling... Tried HDRepair and Norton Utilities... still the same..

setting startup disk on OS 9 - Any idea why this script won't work: tell application "Startup Disk" activate set startup disk alias to "Macintosh HD:" as alias end tell Couldn't Apple make things simple in Applescript and just have the command be something ...

Startup sound MacOS X? - Hello, in MacOS 7-9 it was easy to play a startup sound when the Finder boots up. How can I do this in MacOS X? Can I play a aiff-sound file with AppleScript without opening another application? Steffen -- Die Newton-Seite:..

Startup Item (AppleScript) Keeps Bouncing - I have six items in my Startup Items list, one of them being a simple AppleScript which calls for the unmounting of an internal hard drive, the system being booted from an external firewire hard drive. The problem is that most of the time, but not..
   Macintosh computer (Home) -> Apple Scripts All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]