#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    13
    Rep Power
    0

    Angry cron job giving an rc=1


    Hi Guys I have a script which I have created to automate ftp between two boxes
    the script does two main jobs
    1. it copies a file which starts with the LIF* from a directory to another direcory and renames the file D* file then it ftps out another box and then archives both the LIF*and D* files

    now this script works alright when you run on the command line but when you put it into a cron job it fails with an rc=1 below is a copy of the file

    Code:
     /usr/bin/ksh 
    # This script is designed to Automate FTP between to host
    # if you have any question contact me @ 
    # Makes a backup of the old ~/.netrc file
    
    # Copy the LIF files to dodatftp directory
    
    cp /home/tranman/ora_files_magnet/MLC_TRANSFERRED/LIF* /home/tranman/ora_file_magnet/MLC_TRANSFERRED/"`date '+D%y%m%d'`"
    #
    #
    #
    cp /.netrc /netrc.bak
    
    # Configures a new ~/.netrc
    rm /.netrc
    echo machine ttialsi > /.netrc
    echo login super_magnet >> /.netrc
    echo password password >> /.netrc
    chmod go-rwx /.netrc
    echo dodatftp log file > dodatftp.log
    echo Begin conection at: >> dodatftp.log
    date >> dodatftp.log
    ftp -i<<**
    open ttialsi 
    binary
    lcd /home/tranman/ora_file_magnet/MLC_TRANSFERRED
    mput D*
    
    bye
    **
    # Now do an Archive of the ftped file
    cd /home/tranman/ora_file_magnet/MLC_TRANSFERRED
    mv D* Archived/
    cd /home/tranman/ora_files_magnet/MLC_TRANSFERRED
    mv LIF* Archived/
    
    echo End connection at: >> dodatftp.log
    date >> dodatftp.log
    # End of dodatftp script
    And when I tail /var/cron/log
    i get

    Code:
    >  CMD: /usr/local/bin/dodatftp
    >  root 19103 c Mon Nov  3 15:28:00 2003
    <  root 19103 c Mon Nov  3 15:28:00 2003 rc=1
    >  CMD: /usr/local/bin/dodatftp
    >  root 19213 c Mon Nov  3 15:52:00 2003
    <  root 19213 c Mon Nov  3 15:52:01 2003 rc=1


    On both boxes I am running solaris 2.8
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    121
    Rep Power
    12
    This is an older post, you are still having problems? I see a lot of potential issues, but I'm not sure which is causing your problem. I'll mention the big three:

    1. You need "#! /usr/bin/ksh" as your first statement. As it is, your cron job will run under the bourne shell. If you run it from a ksh command line, ksh will run it.

    2. If you care about the return code, specify it. Your last statement should be "exit 0".

    3. "ftp -i <<**" is a dangerous statement. ksh will never expand word in something like "<<word", but that's not true of all shells. I would switch to <<doc.end or something just to be safe.

    If you're still having trouble, make your second line be something like:
    exec >/tmp/script.out 2>&1
    and post the contents of script.out.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    13
    Rep Power
    0
    Thanks M8
    I have sorted it out after looking at my crontab more closely I noticed that I had one to many * in the statement

IMN logo majestic logo threadwatch logo seochat tools logo