If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Crontab/Shell Output problem

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-11-08, 13:05
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
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 17:08.
Reply With Quote
  #2 (permalink)  
Old 09-12-08, 10:40
jamesadennis jamesadennis is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 09-12-08, 11:51
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
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" )
Reply With Quote
  #4 (permalink)  
Old 09-12-08, 17:24
mdx34 mdx34 is offline
Registered User
 
Join Date: Oct 2004
Posts: 238
Someone helped me out and it is fixed.....Thanks to all..........


ftp -v 198.18.18.51 | tee /root/ReportsFtp.log
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On