IBM developerWorks
           UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old November 3rd, 2003, 10:45 AM
alaoea alaoea is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 13 alaoea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to alaoea
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

Reply With Quote
  #2  
Old November 30th, 2003, 12:54 PM
Perderabo Perderabo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 121 Perderabo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 54 sec
Reputation Power: 5
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.

Reply With Quote
  #3  
Old November 30th, 2003, 11:47 PM
alaoea alaoea is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 13 alaoea User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to alaoea
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

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > cron job giving an rc=1


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway