linux - need bash script to strip version in a binary file and compare to db version -
trying setup bash script version in binary file versions included thinking have strip out audit_trail_#_##_a-z,1-9
this have far suggestions
#!/bin/bash echo searching fmx files audit_trail form version file in `/bin/ls *.fmx` current_release=`strings $file |sed "s/\"audit_trail/notneeded/" |grep -i "audit_trail_8" |sed "s/audit\_trail\_/audit\-trail /" |sed "s/\_/\./g" |sed "s/\.[a-z,a-z]/\.00/" |awk '{print substr($0,0,18)}' |awk '{print $2}'` export form=$(echo "$file" | cut -f1 -d'.') export dbform=`echo $form |awk '{print toupper($0)}'` echo "formname" $form sqlplus -s /nolog <<eof connect system/xxx@xxxxx set echo on whenever oserror exit 88 whenever sqlerror exit 1 spool forms.lst select guraobj_current_version bansecr.guraobj guraobj_object = '$dbform'; spool off exit eof echo $file $current_release done output
bash-4.1$ ./find_current_release_fmx_db.shl + ./find_current_release_fmx_db.shl ./find_current_release_fmx_db.shl: line 1: !/bin/bash: no such file or directory searching fmx files audit_trail form version formname peaempl from database
guraobj_cu ---------- 8.11.2 peaempl.fmx
from compiled form
8.0 8.0 8.0.00 8.0.00 8.1.0. 8.1.0. 8.2.00 8.2.00 8.3 8.3 8.4 8.4 8.7.1 8.7.1 8.7.1. 8.7.1. 8.8.0. 8.8.0. 8.8.1. 8.8.1. **the 1 need 8.11.2** 8.11.2 8.1.0. 8.8.0. 8.7.1. 8.11.2 8.0.00 8.2.00 8.0 8.3 8.4 8.8.1. 8.7.1 desired output
8.11.2
any appreciated
let's start tidying script not use many pipes , commands, more robust, etc.:
#!/bin/bash printf 'searching fmx files audit_trail form version\n' file in *.fmx current_release=$(strings "$file" | awk '<something>') form="${file%%.}" dbform="${form^^}" printf 'formname %s\n' "$form" sqlplus -s /nolog <<eof connect system/xxx@xxxxx set echo on whenever oserror exit 88 whenever sqlerror exit 1 spool forms.lst select guraobj_current_version bansecr.guraobj guraobj_object = '$dbform'; spool off exit eof printf '%s %s\n' "$file" "$current_release" done now need know <something> in awk command should be. couldn't figure out chain of piped commands seem adding stuff , removing again , escaping things shouldn't need escaped, etc. once show sample output of strings , want awk script convert should obvious.
Comments
Post a Comment