Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Grimsrud

macrumors member
Original poster
Aug 11, 2010
67
0
I'm trying to set up a process that will open a webpage at a certain time of the day, but when I save it in Automator, it does not open up iCal and create a calendar event as a couple guides (including the official one from Apple) I've read said it should. Is this an compatibility issue between Automator and the newest version of iCal that comes with Lion, or am I just missing something obvious?
 
I wouldn't use Automator. I'd use a launch daemon and an AppleScript, but those take some learning. Could you attach the action you made so I could take a look? Zip it first.
 
The solution

It's not as difficult as it seems, although I had to work it out (again). I tried to use an automator application that I used frequently once upon a time, to launch an app every evening at a specific time, within iCal but that no longer worked.

All you need to do is create a new iCal Alarm from the "document type" dialog when you first open Automator.

Create your workflow, click save and it automagically adds it to a calendar event, so you can set time and date etc.

No need to do anything else.

AW
 
"automagically" not so much for me.

The procedure runs just fine for me if I run it manually, but once scheduled, nothing happens (Other than the App showing up in Activity Monitor).
 
The key elements are:

1) After you create the workflow, you do a "Save as..." this is where you get to name it, but there's a pulldown selection to decide if you want to save it as a "Workflow" or as an "Application". You MUST save it as type "Application". If you save it as a "Workflow" then it'll just open in the Automator GUI but it won't run. If you save it as an "Application" then it'll actually run whenever it is opened.

2) On my macs, if I select the template to create an iCal action, it doesn't automatically open iCal and let me fill in the details for when I want it launched. Not sure why... but I've tried it on several Macs and they're all the same (even though I'm following Apple's own documentation for Automator which says it's supposed to do that.) HOWEVER... I find that I can get around this by just creating my own iCal appointment, and in the "alert" field, set the alert to "open file". There's a sub-type that will default to "iCal". Click on the word "iCal" and in the flyout menu, select "other". This will pop open a finder window which will allow you to navigate to and select the Automator "application" you created in the above step.

After doing both of these things (making sure it's saved as type "Application" and manually creating the iCal entry via the "Open File" alert option) it does work.

On the advice of another webpage, I added a new calendar to iCal (rather than using one of the default "Home" or "Work" calendars) called "Automator" and used that to schedule the daily recurring event. I then un-check the calendar from the list of calendars to display (this doesn't delete it ... it's still there and it still runs everything, it just hides it so that you don't see the appointment for the various actions you want automator to perform on schedule.)
 
I followed tcampb01's instructions and it 'seemed' to work, but then I just realized it hasn't run since the date I originally created the recurring event in iCal (using the method described to create a new calendar, Automator, and hiding it from view). The recurring event in iCal looks right; if I manually run the Automator application it all works, but it's not being kicked off every night at 5 am.

Any ideas?
 
@RossW

Can you attach your Automator app to your post or describe what the app does? You could easily create a launch agent for this kind of recurring event.
There's even an app that can do all the work for you called Lingon.

Info : http://www.peterborgapps.com/lingon/

I don't think it's the Automator actions that are the problem - I now see a popup alert from iCal saying that the 'Open file' alert doesn't run because the .app file couldn't be opened (See attached file).
 

Attachments

  • iCal event error.png
    iCal event error.png
    28 KB · Views: 149
When using a launch agent there's no need for iCal. You said the Automator app runs fine manually but in combination with iCal it clearly doesn't. Check your logs in the Console application for more information why the app couldn't be opened.
 
I tried Lingon but no luck there either (pointing to my Automator app). Are there logs for that?
 
Have you checked the Console application? Can you attach your Automator app to your post or describe what the app does? Post a screenshot of the XML configuration file that Lingon made. It should be in your ~/Library/Launch Agents directory. Based on the iCal message it has something to do with backing up your Comic collection. I'm assuming copying files of some filetype from one location to another. If that's the case it should be scriptable with Applescript. Or is there some other kind of voodoo inside the app?


Example :

You could save a property list like this as ~/Library/LaunchAgents/some.label.plist.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC -//Apple Computer//DTD PLIST 1.0//EN
http://www.apple.com/DTDs/PropertyList-1.0.dtd>
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>some.label</string>
    <key>ProgramArguments</key>
    <array>
        <string>automator</string>
        <string>/path/to/example.workflow</string>
     </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

It has to be loaded first by running in Terminal :

Code:
launchctl load ~/Library/LaunchAgents/some.label.plist

or logging out and back in once.

Check the Console application and filter for launch.
 

Attachments

  • Picture 2.png
    Picture 2.png
    156.2 KB · Views: 189
Last edited:
No Voodoo. Sole file copy from one folder to another scheduled for once a day (thru iCal it Lingon - neither works). I'd be happy with doing AppleScript but (a) don't have any experience with it, and (b) I thought an iCal alarm won't run an AppleScript file with a recent OS update)
 
I'd be happy with doing AppleScript but (a) don't have any experience with it, and (b) I thought an iCal alarm won't run an AppleScript file with a recent OS update)

a) I could do that for you if you provide me with the information I need.
b) You're right about that. Fortunately a launch agent doesn't have that restriction.(at least to my knowledge I could be wrong)
c) Only trying to help. It's a free world the choice is yours.
 
Thanks kryten2 - believe me when I say i really appreciate the help. I've attached some screenshots which I hope explain what I'm trying to do. Basically, I'm just copying a file from a folder in Dropbox to a local folder on my Mac using an Automator .app file. I've included the Lingon config screen and my Terminal output.
 

Attachments

  • Lingon_Info.png
    Lingon_Info.png
    140.5 KB · Views: 169
  • Terminal_Info.png
    Terminal_Info.png
    223.7 KB · Views: 168
  • Automator_Info.png
    Automator_Info.png
    172.8 KB · Views: 147
Sorry, I was a little busy answering another post in another thread. Did you notice the line 12:47:53 PM (Backup Comic Collection) Unknown key : LingonWhat. Could you attach the configuration file that Lingon made? It should be in the LaunchAgents folder that's in your user's Library folder and should have Backup Comic Collection in its name. I attached an example screenshot of mine. Give me a couple of minutes to absorb the information in your post.

Edit : Can't really make out the paths to the folder in Dropbox and the local folder. Post a screenshot after you run the workflow but when you do first click the results thingy in both actions so the actions shows the resulting paths or screenshots from Finder like mine which show the path bar.
 

Attachments

  • Picture 3.png
    Picture 3.png
    181.5 KB · Views: 153
Last edited:
Here's my plist file. The actual name of the Automator .app file is "Automator_App_Comic_Collection_Backup.app"
 

Attachments

  • Backup Comic Collection.txt
    739 bytes · Views: 230
Here's a screenshot of the workflow while running (Automator crashed for the first time on me so it didn't finish).

Dropbox location of source file: Comics\RossW.cmp
Documents location of target: Documents\Comics\Comic Collector\Backup from Dropbox

Is it the spaces in the target folder path?
 

Attachments

  • Automator_Wrkflw_Running.png
    Automator_Wrkflw_Running.png
    236.2 KB · Views: 211
Copy this script in ScriptEditor and run it to see if it copies the file from the right source to the right destination.

Code:
set theSourceFolder to (path to home folder as text) & "Dropbox:Comics:" as alias
set theDestinationFolder to (path to documents folder as text) & "Comics:Comic Collector:Backup from Dropbox:" as alias
tell application "Finder"
	set theContents to entire contents of theSourceFolder
	duplicate theContents to theDestinationFolder with replacing
end tell
 
It works! Of course, I have no idea how to schedule this to run every day with Lingon. Do I need to just point Lingon to a saved AppleScript file, or does it need more parameters in the What field?
 
Spoke (slightly) too soon - AppleScript popped up an error saying the AppleEvent timed out (the file is big - about 1.8 GB) although the copy seemed to continue and eventually completed just fine.
 

Attachments

  • AppleScript_Err.png
    AppleScript_Err.png
    101.2 KB · Views: 199
Ok, now we're getting somewhere. The time out should be solved with an added statement in the script. Don't know it by heart, will have to look it up. Shouldn't take too long. I would make a plist manually if you can and leave Lingon out of it.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>some.label</string>
	<key>Program</key>
	<string>/usr/bin/osascript</string>
	<key>ProgramArguments</key>
	<array>
		<string>osascript</string>
		<string>/Users/yourusername/Library/Scripts/nameofyourscript.scpt</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>StartCalendarInterval</key>
	<dict>
		<key>Hour</key>
		<integer>12</integer>
		<key>Minute</key>
		<integer>36</integer>
	</dict>
</dict>
</plist>


Change some.label and the path to your script line and the values in the StartCalendarInterval to see if it kicks in at the specified time.
I post a modified script in a few minutes.
Remember to load it with :

Code:
launchctl load ~/Library/LaunchAgents/nameofyour.plist

Edit : If an event takes longer than two minutes, the Apple Event Manager reports a time-out error. If 5 minutes isn't enough increase the timeout.

Code:
set theSourceFolder to (path to home folder as text) & "Dropbox:Comics:" as alias
set theDestinationFolder to (path to documents folder as text) & "Comics:Comic Collector:Backup from Dropbox:" as alias
tell application "Finder"
	set theContents to entire contents of theSourceFolder
	with timeout of 300 seconds
		duplicate theContents to theDestinationFolder with replacing
	end timeout
end tell
 
Last edited:
Had to bump up the timeout, but I think everything is working now (my plist file attached).

Thanks so much kryten2!
 

Attachments

  • Backup Comic Collection from Dropbox.txt
    698 bytes · Views: 268
All you need to do is create a new iCal Alarm from the "document type" dialog when you first open Automator.

Create your workflow, click save and it automagically adds it to a calendar event, so you can set time and date etc.

How do you get at this iCal Alarm later if you want to edit/modify it?

Update: Ah, found it in my Open Recent menu and then traced it back to ~/Library/Workflows/Applications/iCal/ folder.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.