newbie request

Hello People…

Got some problems makeing a script repeat some shell commands
i got a shell script called i my home folder, and i need an AS
that will run this shell script every 3H, when is use this command

do shell script (“”)

the script is NOT working, if i run ./ from Terminal it works fine.

but still i need it to run every 3 hour

thx mkh

What you need to do is save the script as a atay-open application and use a idle handler.

on idle
	do shell script "/path/to/"
	return 10800 --this is in seconds
end idle

WoW, that was FAST, thx alot, but im still getting the same error when trying to run the script.

what do is mount a image, transfer files and unmount image again.

but only working if run manually in Terminal…

What is the specific error that you are receiving?

Can you post the contents of the script itself? Occasionally some scripts need modification when running from within an AppleScript. One large resaon for this is “do shell script” operates within the “sh” shell which, generally, is not a users default shell.

as of now im using the script you gave me.
and since my is working direct from Terminal i guess the error must be located in the AS script
im not getting any errors, my script does mount my image, but i cant access it. i can if using Terminal.

so i guess i must get Terminal to run the process, but, since im using Terminal for irssi, i dont what to interfere whit that.


Locate backup drive

if [ ! -d $VOL ]; then
echo 1>&2 Error: Backup volume not found.
exit 1

Locate image

if [ ! -f $IMAGE ]; then
echo Backup image not found, Creating…
hdiutil create -quiet -size $IMAGE_SIZE -type SPARSE -fs HFS+J
-volname $BACKUP_NAME -uid 0 -gid 80 -mode 0775 $IMAGE

Mount image

MOUNT=hdiutil attach -owners on $IMAGE | grep Apple_HFS | awk '{print $3}'

if [ ! -d $MOUNT ]; then # Did the image mount successfully?
echo 1>&2 Error: Could not mount backup image.
exit 1

Turn Spotlight indexing off for backup image

mdutil -i off $MOUNT >/dev/null

Run backup using rdiff-backup

rdiff-backup --force ~/Library/Preferences/ $MOUNT/Library/Preferences/date +%d_%m_%y/

Get the disk space usage, and give a warning if necessary

USAGE=df -h $MOUNT | grep -v Capacity | awk '{print $5}'
if [ $USAGE = “100%” ] || [ $USAGE = $ALERT ] || [[ $USAGE > $ALERT ]]; then
echo Warning: Disk usage is $USAGE

Unmount the backup disk image

hdiutil detach -quiet -force $MOUNT

exit 0[/code]

Well given the only real AppleScript command is to run your script and part of it is working, the volume is mounting afterall, I would guess the issue is not with AppleScript itself, but rather the shell script when run from within Applescript.

If possible I would suggest pathing out your commands used within your shell script and then give it another go.

I agree with James; the next test should be something like this:

set shell_script_path to "/Users/casdvm/bin/"
do shell script (quoted form of shell_script_path)

You should also consider setting the do shell script to a variable, since you have an echo command in there, just in case there is a string to return:

set shell_script_path to "/Users/casdvm/bin/"
set shell_reply to do shell script (quoted form of shell_script_path)
display dialog shell_reply

Good luck,

wuhu, thx alot guys, i think i made it work. :slight_smile:

Okay, maby not :frowning: if used in script editor it is working, as soon as i save as an .app
i get the same problem as before, if run from script editor it is working

on run
end run

on idle
	return 10800
end idle

on Backup()
	set shell_script_path to "/Users/mkh79/Deamons/" as text
	do shell script (quoted form of shell_script_path)
end Backup

Good morning mkh,

So when you save it as an app what part is not working? It doesn’t run at all? OR It doesn’t repeat every 3 hours. Remember that you need to save your app with the “stay open” setting.

i was using stay open event, but

all my problems are over (regarding to running shellscript that is :smiley:

using crontab for now, which is working… but thx for all your help…

the problem was NOT applescript but the PATH to rdiff-backup located in the

Working now.