Shell Script not working in cron...

Discussion in 'Mac Programming' started by guybowden, Apr 7, 2009.

  1. macrumors newbie

    Joined:
    Apr 7, 2009
    #1
    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:


    Code:
    #!/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
    Code:
    #!/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
    Code:
    #!/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....
     
  2. macrumors 6502

    Joined:
    Jun 22, 2006
    #2
    MacOSX doesn't use the cron mechanism at all. You have to suffice with the new launchd.
     

Share This Page