PDA

View Full Version : Shell Script not working in cron...




guybowden
Apr 7, 2009, 07:58 PM
Hi,

I'm trying to set up a way to automatically upload my nzb files to the watch folder on the ATV - I've got a shellscript that works fine when run in the terminal, but no so when it runs via cron...

Any tips or advice would be great!

first script:
tars up all my new nzb files and runs the scp and ssh shell scripts:


#!/bin/sh
cd /Users/guy/Downloads
/sw/bin/tar -cf nzb.tar *.nzb

/Users/guy/Code/shellscripts/scp.sh
sleep 5
/Users/guy/Code/shellscripts/ssh.sh

rm nzb.tar
rm *.nzb


Then scp.sh - uploads the tar to the ATV

#!/usr/bin/expect -f
cd /Users/guy/Downloads
spawn /usr/bin/scp nzb.tar frontrow@appletv.local:Downloads/nzb
expect -re ".*sword.*"
send "frontrow\r"
interact


Then ssh.sh - untars the uploaded tar file - and deletes it off the ATV

#!/usr/bin/expect -f

spawn /usr/bin/ssh frontrow@appletv.local
#######################
expect -re ".*sword.*"
send "frontrow\r"
sleep 1
expect -re ".*$.*"
send "cd ~/Downloads/nzb\r"
sleep 1
expect -re ".*$.*"
send "tar -xvf nzb.tar\r"
sleep 1
expect -re ".*$.*"
send "rm nzb.tar\r"
sleep 1
expect -re ".*$.*"
send "exit\r"
interact


As I said - this runs fine in the terminal window, just not as a cron job....



mmulin
Apr 7, 2009, 09:56 PM
MacOSX doesn't use the cron mechanism at all. You have to suffice with the new launchd.