Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2004
    Posts
    268

    Unanswered: Crontab/Shell Output problem

    Red Hat Enterprise Linux WS release 3 (Taroon Update 9)

    I have a FTP job where I use .netrc. I have a shell script also. When I run the shell script I get the output log file with the FTP details but when I run it from a crontab job, I get only;

    Interactive mode off.
    Local directory now /home/nasdrnap/extracts/files

    If I run the Shell script, I get (and this is what I want to get);

    Connected to 198.18.18.51.
    220 FTPSERV1 Microsoft FTP Service (Version 5.0).
    500 'AUTH GSSAPI': command not understood
    500 'AUTH KERBEROS_V4': command not understood
    331 Password required for ftpuser1.
    230 User ftpuser1 logged in.
    prompt
    Interactive mode off.
    lcd /home/nasdrnap/extracts/files
    Local directory now /home/nasdrnap/extracts/files
    cd /PRA/Client_out
    250 CWD command successful.
    put Reports.txt
    local: Reports.txt remote: Reports.txt
    227 Entering Passive Mode (198.18.18.51,19,75).
    125 Data connection already open; Transfer starting.
    226 Transfer complete.
    190059 bytes sent in 0.027 seconds (7e+03 Kbytes/s)
    put filesent.trg
    local: filesent.trg remote: filesent.trg
    227 Entering Passive Mode (198.18.18.51,19,76).
    125 Data connection already open; Transfer starting.
    226 Transfer complete.
    94 bytes sent in 2.9e-05 seconds (3.2e+03 Kbytes/s)
    quit
    221

    ----------------My Shell Script----------------------
    su - db2inst1 "-c /home/db2inst1/scripts/Creport.sh"
    cd /home/nasdrnap/extracts/files/archive
    rm Reports.txt
    cp /home/nasdrnap/extracts/files/Reports.txt .
    ftp 198.18.18.51 | tee /root/ReportsFtp.log

    ----------------My .netrc file----------------------------
    machine 198.18.18.51
    login ftpuser1
    password MU74N%IH
    macdef init
    prompt
    lcd /home/nasdrnap/extracts/files
    cd /PRA/Client_out
    put Reports.txt
    put filesent.trg
    quit

    --------------My crontab entry is-------------------
    00 21 * * 1,2,3,4,5 /root/CLNTReport.sh

    -------------------------------------------------

    How can I get the same output in the log file (ReportsFtp.log) after running from the crontab ?

    Thanks for any help.

    Mike
    Last edited by mdx34; 09-11-08 at 18:08.

  2. #2
    Join Date
    Sep 2008
    Posts
    2
    It seems that you're saying if you run the script from the command line, you see the ouput you want on your monitor/terminal. Correct? What you need to is redirect the output to a log file as follows:
    00 21 * * 1,2,3,4,5 /root/CLNTReport.sh > logfile.log 2>&1

  3. #3
    Join Date
    Oct 2004
    Posts
    268
    I already tried that. It doesn't work. I get the same;

    Interactive mode off.
    Local directory now /home/nasdrnap/extracts/files

    I get the previous command's logs in the shell script i.e.

    su - db2inst1 "-c /home/db2inst1/scripts/Creport.sh"
    cd /home/nasdrnap/extracts/files/archive
    rm Reports.txt
    cp /home/nasdrnap/extracts/files/Reports.txt .


    BUT not the result of the line;

    ftp 198.18.18.51 | tee /root/ReportsFtp.log

    (With or without " | tee /root/ReportsFtp.log" )

  4. #4
    Join Date
    Oct 2004
    Posts
    268
    Someone helped me out and it is fixed.....Thanks to all..........


    ftp -v 198.18.18.51 | tee /root/ReportsFtp.log

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •