LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-12-2008, 03:14 PM   #1
mdx34
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Rep: Reputation: 0
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.
 
Old 09-12-2008, 03:48 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,958

Rep: Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672
Quote:
Originally Posted by mdx34 View Post
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.
 
Old 09-12-2008, 04:05 PM   #3
mdx34
LQ Newbie
 
Registered: Sep 2008
Posts: 3

Original Poster
Rep: Reputation: 0
That did not do it either.........I put 'echo' also but still no help....Thanks for your reply though............
 
Old 09-12-2008, 04:28 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
Have you tried the -v option of ftp?
Code:
ftp -v 198.18.18.51 | tee /root/ReportsFtp.log
 
Old 09-12-2008, 04:29 PM   #5
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,958

Rep: Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672
Quote:
Originally Posted by colucix View Post
Have you tried the -v option of ftp?
Code:
ftp -v 198.18.18.51 | tee /root/ReportsFtp.log
Good call....
 
Old 09-12-2008, 05:31 PM   #6
mdx34
LQ Newbie
 
Registered: Sep 2008
Posts: 3

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange output log of crontab kuangchen Linux - Newbie 1 05-30-2008 05:13 AM
crontab job and run on shell sunhui Linux - Software 1 02-13-2007 06:35 AM
Odd problem with making a variable the output of a command in a shell script linux=future Programming 3 12-13-2005 10:45 PM
Directing xosd output to X display from crontab BWebb Linux - General 3 06-30-2005 02:09 PM
Shell script running via crontab problem. thetruethugg Linux - Software 13 12-19-2003 09:56 PM


All times are GMT -5. The time now is 10:18 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration