LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Crontab/Shell Output problem (https://www.linuxquestions.org/questions/linux-newbie-8/crontab-shell-output-problem-669534/)

mdx34 09-12-2008 02:14 PM

Crontab/Shell Output problem
 
I have posted this question to another group where I did not get it resolved. May be it was the wrong group to post it. Here is my 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 ?

I already tried something like

00 21 * * 1,2,3,4,5 /root/CLNTReport.sh > logfile.log 2>&1

but I got the same:

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

only.

Thanks for any help.

Mike.

TB0ne 09-12-2008 02:48 PM

Quote:

Originally Posted by mdx34 (Post 3278579)
I have posted this question to another group where I did not get it resolved. May be it was the wrong group to post it. Here is my problem:

Try:

2>&1&

at the end of your cron statement. Also, since those commands are being shoveled out by your script (STDIN essentially), they may not echo. You could always put echo statements in your script, which could barf out the right lines of data as it goes, which may solve your problem.

mdx34 09-12-2008 03:05 PM

That did not do it either.........I put 'echo' also but still no help....Thanks for your reply though............

colucix 09-12-2008 03:28 PM

Have you tried the -v option of ftp?
Code:

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

TB0ne 09-12-2008 03:29 PM

Quote:

Originally Posted by colucix (Post 3278637)
Have you tried the -v option of ftp?
Code:

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

Good call....

mdx34 09-12-2008 04:31 PM

That did it. Thank you all.......Is this mean I forgot the -v (verbose) option ?. Shame on me !


All times are GMT -5. The time now is 10:04 AM.