• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Fwd: Need to run script periodically (updated for your info)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: Need to run script periodically (updated for your info)


  • Subject: Fwd: Need to run script periodically (updated for your info)
  • From: Brian Christmas <email@hidden>
  • Date: Thu, 16 Feb 2017 02:27:21 +1100

For your information.

This example just runs from the desktop, but shows my problem.

I found the script (at the bottom) was still staying active, just ‘sleeping', through to re-running, and a beachball, so had to add a ‘Quit’ script to the shell script. Works very well; so well in fact, that I haven’t found a way to turn it OFF from any external methods.

So, I added a line to check for the ‘Interarchy’ process, which the script depends on, and quit it the only way I found that worked, an ‘error -128’.

Hope someone finds it useful. It definitely quits, and restarts 5 minutes later, in my real working version.

Regards

Santa

Example…

on run
say 1
tell application "Finder"
if not (exists process "Interarchy") then error -128
end tell
do shell script ("sleep 5”) # Replaces code
say 2
do shell script "/usr/bin/osascript -e 'tell application \"System Events\" to tell script (((path to desktop as text) & \"ftp Downloader.scpt\" as text) as alias) to quit'&&sleep 20&&/usr/bin/osascript -e 'run script (((path to desktop as text ) & \"ftp Downloader.scpt\"  as text) as alias)' "
end run


on quit
error -128
end quit


Begin forwarded message:

From: Brian Christmas <email@hidden>
Subject: Re: Need to run script periodically
Date: 13 February 2017 at 4:42:52 pm AEDT
To: Applescript Users <email@hidden>

Thank you everyone for the tips.

I am actually trying to re-cycle the folder action script every minute, from within itself.

I needed to explicitly address the ‘on run’ handler’, to bypass the intial handler called by the triggering of the folder action.

I found that writing the ftp folder details to a .dat file was very unreliable, often Sierra would throw a ‘you don’t have permission’ error, even after I’d already written to the file, and erased it.

So, every minute, new handlers check every ftp folder for newly added downloaded ftp transfer files, and try and write to the .dat file if any are found.

It just persists in trying. Won’t write to the file on one pass, a minute later it will.

I solved the 'call on run’ by using an alias. An applescript I wrote to try and address the Appplescript file kept adding a colon on the file path, even when I wasn’t using an alias. So…

do shell script "sleep 60&&/usr/bin/osascript -e 'run script (((path to Folder Action scripts folder from user domain as text ) & \"ftp Downloader.scpt\"  as text) as alias)' "

Remember, the above code is embedded within the script being called, and runs just before it quits.

Thanks again. Lots learnt from your help.

Regards

Santa


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Need to run script periodically (updated for your info)
      • From: Christopher Stone <email@hidden>
References: 
 >Re: Need to run script periodically (From: Brian Christmas <email@hidden>)

  • Prev by Date: Anyone familiar with disappearing Adobe Illustrator dictionaries?
  • Next by Date: Re: Need to run script periodically (updated for your info)
  • Previous by thread: Re: Need to run script periodically
  • Next by thread: Re: Need to run script periodically (updated for your info)
  • Index(es):
    • Date
    • Thread