View Full Version : osascript command fails when run by cron
wzpgsr
01-23-2002, 06:43 PM
Any ideas why this script would mount the volume when the parent script is run from the command line, but not when run from cron?
#!/bin/sh
if [ ! -d "/Volumes/backup" ]; then
/usr/bin/osascript /Users/me/Library/Scripts/src/mount_backup_nfs.txt
fi
The contents of the 'mount_backup_nfs.txt' look like this:
tell application "Finder"
open location "nfs://backup/path/to/backup"
end tell
escowles
01-23-2002, 07:57 PM
The usual reason that scripts that work from the command line would fail from cron is that cron has a different environment than the regular command line -- the path, environment variables, etc. must be explicitly included, there is no terminal, etc.
Since the paths are all absolute, I would guess that the lack of a terminal is the problem. I would try one of two things:
1. Use /sbin/mount_nfs to mount the NFS share.
2. Not use cron -- Find some GUI scheduling tool that would run in the dock.
-Esme
mervTormel
01-23-2002, 08:02 PM
any errors? check console?
also, you might want to add some stderr redirection to that sh script.
that might give you some more to go on
something like
exec 2>/pathto/errs.out
at the top of your cron'd script
then look in errs.out for what happened.
maybe some sort of osascript quoting issue? ima dunno.
wzpgsr
01-23-2002, 09:31 PM
Thanks for the suggestions. The script doesn't work when cron'd because the applescript is telling the Finder to do something: cron doesn't have an instance of the Finder running! I am using mount_nfs now instead of the applescript.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.