#1
  1. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    277
    Rep Power
    0

    Cron job to FTP errors


    I'm trying to set up a cron job to run as root so I can ftp some mysql dump files to another server, but I keep getting errors from the beginning.

    Here's what I'm running

    #!/bin/sh
    cd ..
    cd backups
    ftp myservername
    user ftpuser ftppass
    put backupfile.sql
    bye

    It errors on "cd backups" stating that the folder doesnt exist. Then when it tries to log into my ftp server, it says login failed. If I run the exact same commands in the same order, from a command line, it works perfectly fine. So I don't understand what the cron job is getting confused about. I have the sh file set to 777 and running as root.
  2. #2
  3. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    277
    Rep Power
    0
    So no one has any idea whatsoever huh? Not a clue huh?
    Last edited by millercepbs; April 8th, 2009 at 03:01 PM.
  4. #3
  5. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    277
    Rep Power
    0
    Comeon guys. Someone has to be able to help me with this. It's got to be something simple that I'm missing.
  6. #4
  7. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2006
    Posts
    277
    Rep Power
    0
    Well thanks for the complete lack of help folks. I managed to finally figure out what the deal was. It still seems completely retarted that something that works in the command line, has to be altered this much to work in a script. Here's the working version for anyone that this might help...cause I actually will respond.

    #!/bin/sh
    USERNAME="myusername"
    PASSWORD="mypassword"
    SERVER="ftp.domain.com"
    cd ..
    cd /backups
    /usr/bin/ftp -n $SERVER <<END_SCRIPT
    user $USERNAME $PASSWORD
    put file
    quit
    bye

IMN logo majestic logo threadwatch logo seochat tools logo