![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Count not correct | popeye | Shell Programming and Scripting | 3 | 04-22-2008 01:50 PM |
| Tar-ing the correct directories | new2ss | UNIX for Dummies Questions & Answers | 1 | 11-08-2007 10:15 PM |
| plz correct this | wannalearn | Shell Programming and Scripting | 8 | 04-26-2007 08:56 AM |
| Error : Field $() is not correct | abbey | Shell Programming and Scripting | 3 | 06-20-2006 04:01 AM |
| My dns entries - are they correct ? | matt2kjones | IP Networking | 1 | 10-01-2002 12:28 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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" |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|