#! /bin/csh
set umr=UMR
foreach i ( `ls`)
set file_nm=$i
set bh_nm=`echo $file_nm | cut -d"_" -f2`
if($bh_nm !=$umr) then
{
set bh_ext=`echo $file_nm | cut -d"_" -f4`
set bh_num_nm="$bh_nm $bh_ext a .txt"
mv $file_nm $bh_num_nm
}
else
if ($bh_nm ==$umr) then
{
set um_ext=`echo $file_nm | cut -d"_" -f5`
if ($um_ext=="1.txt") then set um_ext_new=1
else
if ($um_ext=="2.txt") then set um_ext_new=2
endif
set umr_bh=`echo $file_nm | cut -d"_" -f3`
set umr_nm= "$umr_bh $um_ext_new b .txt"
mv $file_nm $umr_nm
}
endif
end
I have an issue with if sytax error, tried running using -x option n could not find any errors but when I run the same from cron I am getting Sytax error sometimes.
I used C shell to write below script and when I ran it from CRON it giving me below error
Your "cron" job on gpsprod3
/archive/SUPPORT/scripts/BUREAU/ALERTS/ALL/processCount/process_count.csh 102
produced the following output:
if: Expression syntax
Any help is much appreciated.
Script:
#!/bin/csh -x
setenv ENV_NO $1
source /archive/SUPPORT/scripts/BUREAU/ALERTS/SetEnvironment
set HOME=/archive/SUPPORT/scripts/BUREAU/ALERTS/ALL/processCount/$1
set LIST="$HOME/pslist.$$"
set LOG=$HOME/LOG_$$
set USERLOGIN=$HOME/user_login.$$
set mailid=" -r xxx@sample.com"
touch $LIST
if ( $1 == "574C" ) then
/usr/ucb/ps -auegwx | grep \/g574cpd\/appl\/gloss\/G574CLIVE_GLOSS\/GLOSS | grep -v grep | grep -v task | grep -v find | grep -v gsb
tools | grep -v 'wc -l' >> $LIST.$$
cat $LIST.$$ | wc -l >> $LIST
else if ( $1 == "I039" ) then
/usr/ucb/ps -auegwx | grep \/ina039pd\/appl\/ina\/INA039\/GLOSS | grep -v grep | grep -v task | grep -v find | grep -v gsbtools | gr
ep -v 'wc -l' >> $LIST.$$
cat $LIST.$$ | wc -l >> $LIST
else if ( $1 == "039" ) then
/usr/ucb/ps -auegwx | grep \/g$1pd\/appl\/gloss\/G$1LIVE_GLOSS\/GLOSS | grep -v grep | grep -v task | grep -v find | grep -v 'wc -l'
| grep -v gsbtools >> $LIST.$$
cat $LIST.$$ | wc -l >> $LIST
else
/usr/ucb/ps -auegwx | grep \/g$1pd\/appl\/gloss\/G$1LIVE_GLOSS\/GLOSS | grep -v grep | grep -v task | grep -v find | grep -v 'wc -l'
| grep -v gsbtools >> $LIST.$$
cat $LIST.$$ | wc -l >> $LIST
endif
echo "number of processes running through PS command" >>$LOG
cat $LIST>> $LOG
$ISQL -w132 -c -b -S $DSQUERY -U $DB_USER -P $DB_PASW << END_OF_SCRIPT >> $USERLOGIN
use $CONTROL_DB
set nocount on
SELECT COUNT(1) FROM user_login WHERE user_code LIKE 'b%' AND status='LIVE'
END_OF_SCRIPT
echo "number of processes running through user_login" >>$LOG
cat $USERLOGIN>> $LOG
$ISQL -w132 -c -b -S $DSQUERY -U $DB_USER -P $DB_PASW << END_OF_SCRIPT >> $USERLOGIN.$$
use $CONTROL_DB
set nocount on
SELECT * FROM user_login WHERE user_code LIKE 'b%' AND status='LIVE'
END_OF_SCRIPT
set proc=`cat $LIST`
set login=`cat $USERLOGIN`
if ( $proc != $login ) then
mailx -s "Processes running differ from user_login entries for $ENV_DESC" $mailid <$LOG
endif