question on a unix script

question on a unix script

Post by Jorg » Sat, 28 Jun 2003 05:49:51



The following script runs some basic commands. The problem I am having
is that I can execute this file manually and it runs fine. But when
trying to execute it with the crontab it runs only certain things on the
script. am i missing a basic step? Any help would be greatly apreciated.

Thanks
Jorge

chmod a+r /usr/nts/cback/CBT*
chmod a+w /usr/nts/cback/CBT*
chmod a+x /usr/nts/cback/CBT*
ls /usr/nts/cback > list.txt
        sed '/./=' list.txt | sed '/./N; s/\n/ /' >> list1.txt
   count=`sed -n '$=' list1.txt`
        if [ "$count" -ge 1 ]
        then
#*******************************************************
cp jbjtmp.txt jbjruncb.txt
#********************************************************
exec < list.txt
  while read var1
    do
      cp /usr/nts/cback/$var1 /usr/nts/cbacklog
    done
#*******************************************************
exec < list.txt
  while read var1
        do
        append /usr/nts/cback/$var1 jbjruncb.txt
        done
#*******************************************************
awk -F"," '{print $1,$2,$3}' jbjruncb.txt | sort -u >> jbjruncb2.txt  #
extracts
 desired columbs from file
sed 's/$/|U/' jbjruncb2.txt > jbjruncb3.txt
sed 's/ /|/g' jbjruncb3.txt > callback.txt
#********************************************************
load_cback.cmd

/u/VrsPrgrm/load/aruba/cback
#********************************************************
#$CMD/initupdate.cmd 1
        sed '/./=' list.txt | sed '/./N; s/\n/ /' >> list1.txt
   count=`sed -n '$=' list1.txt`
        if [ "$count" -ge 2 ]
        then
         $CMD/initupdate.cmd 1"
      fi
#********************************************************
exec < list.txt
        while read var1
        do
        rm /usr/nts/cback/$var1
        done
#*******************************************************
rm list.txt jbjrun* callback.txt list1.txt
        fi

 
 
 

question on a unix script

Post by Fletcher Glen » Sat, 28 Jun 2003 06:31:05


Yes you are.  cron is run with a different environment than exists
in your shell.  You must never assume that any command is in the
path nor can you assume that any environment variable that exists
for you will exist when the cron command is run.

--
Fletcher Glenn
to reply remove NOSPAM from my reply address


Quote:> The following script runs some basic commands. The problem I am having
> is that I can execute this file manually and it runs fine. But when
> trying to execute it with the crontab it runs only certain things on the
> script. am i missing a basic step? Any help would be greatly apreciated.

> Thanks
> Jorge

> chmod a+r /usr/nts/cback/CBT*
> chmod a+w /usr/nts/cback/CBT*
> chmod a+x /usr/nts/cback/CBT*
> ls /usr/nts/cback > list.txt
>         sed '/./=' list.txt | sed '/./N; s/\n/ /' >> list1.txt
>    count=`sed -n '$=' list1.txt`
>         if [ "$count" -ge 1 ]
>         then
> #*******************************************************
> cp jbjtmp.txt jbjruncb.txt
> #********************************************************
> exec < list.txt
>   while read var1
>     do
>       cp /usr/nts/cback/$var1 /usr/nts/cbacklog
>     done
> #*******************************************************
> exec < list.txt
>   while read var1
>         do
>         append /usr/nts/cback/$var1 jbjruncb.txt
>         done
> #*******************************************************
> awk -F"," '{print $1,$2,$3}' jbjruncb.txt | sort -u >> jbjruncb2.txt  #
> extracts
>  desired columbs from file
> sed 's/$/|U/' jbjruncb2.txt > jbjruncb3.txt
> sed 's/ /|/g' jbjruncb3.txt > callback.txt
> #********************************************************
> load_cback.cmd

> /u/VrsPrgrm/load/aruba/cback
> #********************************************************
> #$CMD/initupdate.cmd 1
>         sed '/./=' list.txt | sed '/./N; s/\n/ /' >> list1.txt
>    count=`sed -n '$=' list1.txt`
>         if [ "$count" -ge 2 ]
>         then
>          $CMD/initupdate.cmd 1"
>       fi
> #********************************************************
> exec < list.txt
>         while read var1
>         do
>         rm /usr/nts/cback/$var1
>         done
> #*******************************************************
> rm list.txt jbjrun* callback.txt list1.txt
>         fi


 
 
 

1. unix shell script question ?

prompt> cat test.csh
awk '$4 >= $2' src_file > dest_file

Question:
1) The $2 is intended to be the argument of the "test.csh",
     i.e. test.csh {argument} which is passed to the "awk" utility.
     Then how to avoid that "awk" interpret $2 as its own argument
     in '$4 >= $2' ????

THANKS !!!

2. Is it possible to show the BIOS settings under Linux ?

3. Oracle/Unix shell script question...

4. Raw IP Networking FAQ

5. Unix script (newbie question)

6. Modifying a "rescue floppy"

7. Unix rookie's script question

8. sendmail and <from> information

9. unix script question

10. comp.unix.questions comp.unix.misc comp.unix.sys5.r3

11. A simple unix script question

12. Question on Unix script portability.

13. Unix shell-script question