Correct the error plz


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Correct the error plz
# 1  
Old 05-09-2007
Correct the error plz

Hi,
I'll get a file whose first line comprises of system name, timestamp of file creation and the seq number. System name and seq num I need to other computation. My requirement is, I'll have to check whether the timestamp is greater than current timestamp and also check if the timestamp is older than 24hrs of the current timestamp. If so, then generate the error with the description. I have written the following script but it is not working as desired. Please correct the script..

#!/bin/ksh

eval $(awk 'NR==1 {
printf "sys_nam=\"%s\"\n", substr($0,1,length-17) ## system_name
printf "header_tstamp=\"%s\"\n", substr($0,length-16, 14) ## timestamp
printf "in_seq_num=\"%s\"\n", substr($0, length-2) ## seq_num
}' $1)

header_day=`echo $header_tstamp | cut -c7-2`
sys_tstamp=`date +%Y%m%d%H%M%S`
sys_day=`date +%d`
prev_day=`expr $sys_day - 1`

if [ $header_tstamp > $sys_tstamp ]
then
notice_val="102"
notice_desc="Time stamp incorrect format"
elif [ $header_day < $prev_day ]
then
notice_val="102"
notice_desc="Time stamp incorrect format"
else
notice_val="000"
notice_desc="Success"
fi

echo "$header_tstamp"
echo "$sys_tstamp"
echo "$header_day"
echo "$sys_day"
echo "$prev_day"
echo "$notice_val"
echo "$notice_desc"
# 2  
Old 05-09-2007
Mandab,
Try changing the "<" and ">" in your "if" statements as follows:
Code:
if [ $header_tstamp -gt $sys_tstamp ]
...
elif [ $header_day -lt $prev_day ]

# 3  
Old 05-11-2007
Thank you very much !!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Unable to correct NMONVisualizer java error. Can someone help to decode this java error?

Hello AIX and Java gurus, I have a java error that I have no clue how to resolve. I am trying to run the popular NMONVisualizer utility against a NMON dataset and getting the error as shown below: /db2storage/NMON >java -jar NMONVisualizer_2015-02-02.jar com.ibm.nmon.ReportGenerator... (1 Reply)
Discussion started by: okonita
1 Replies

2. Shell Programming and Scripting

error in shell script while returning values-- urgent issue plz help.

Hi, I have initailized a varaible EBID as typeset Long EBID=0 i am calculating value of EBID using certian formula as below: (( CURR_EBID= ($BANDINDEX << 27) | ($CURR_FREQ << 16) | ($CURR_CELLID << 4) | $CURR_SECTOR_VALUE )) return $CURR_EBID The output is as below: + (( CURR_EBID=... (6 Replies)
Discussion started by: kasanur
6 Replies

3. Shell Programming and Scripting

Can anyone correct the error in this script

ret=`sqlplus -s /nolog << EOF connect $db_user/$db_pwd@$db_sid; SPOOL ./$DirectoryName/TableData.txt; set pagesize 0 feedback off verify off heading off echo off linesize 150 while read var_ack_party_name do select * from bus_event where ack_party_name like... (13 Replies)
Discussion started by: rkrish
13 Replies

4. Shell Programming and Scripting

Please correct the error in the following script

#!/bin/ksh db_user=$DB_USER_NAME db_pwd=$DB_PASSWORD db_sid=$TWO_TASK if ; then echo "\tUsage: MoveUsageProcessing <BC Log file Name>" exit 1 else BCLogFileName=$1 fi grep -i 'MoveUsage daemon needs to run on this account before it can be billed' $1 |awk -F\| '{for(i=0;++i<=NF;) if($i ~... (1 Reply)
Discussion started by: Rajesh Putnala
1 Replies

5. Shell Programming and Scripting

Awk Script Counting of Correct vs. Error Responses

Hello, I have been trying to use an awk script to parse out correct and incorrect answers in a simple tab-delimited text file. I am trying to compare the user's response to the stimulus presented (in this case, an arrow pointing left or right; e.g., "<--" vs. "-->"). I have the data for the... (6 Replies)
Discussion started by: Jahn
6 Replies

6. Shell Programming and Scripting

:-) 1213: Character to numeric conversion error. Plz help

Dear friends, I am new to Unix/Linux. I am trying to run following query but getting an error msg... Please can u people help me in this? Query: echo "select status_ac from db_acct where acct_num=AAA000337" | dbaccess elstest Error: 217: Column (amd000337) not found in any table in the... (2 Replies)
Discussion started by: anushree.a
2 Replies

7. Shell Programming and Scripting

Plz correct my syntax of shell script

Dear all I am still bit new in shell script area.I am writing down a shell script which I guess somewhere wrong so please kindly correct it. I would be greatful for that. What I actually want from this shell script is that it will move all the files one by one to another server which can be... (2 Replies)
Discussion started by: girish.batra
2 Replies

8. Shell Programming and Scripting

plz correct this

grep pattern a.log|grep -e "p1" |cut -d":" -f1,2,3,4,8,9,10|cut -d"/" -f5 -e "p2" |cut -d":" -f1,2,3,4,6|cut -d"/" -f5 >> file Dont know why the above command isnt working :-( can someone correct me... (8 Replies)
Discussion started by: wannalearn
8 Replies

9. Shell Programming and Scripting

Error : Field $() is not correct

Hi All, I'm new to shell scripting. Trying to extract substring using awk script as shown below : Flag=$1 Length=`echo ${#Flag}` NewLen=$Length-2 NewFlag=`echo $Flag|awk '{print substr($Flag,0,$NewLen)}'` echo "New string is : $NewFlag" exit When I execute this script the following... (3 Replies)
Discussion started by: abbey
3 Replies

10. UNIX for Dummies Questions & Answers

plz Help How should I configure cc compiler output file plz help???

i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies
Login or Register to Ask a Question