: !/bin/sh # getSIDMAINTconf outfile carrier sidmainttype SDATE EDATE echo "$0: $@" ############################### # was originally.... #exec getmobconf - "VODAFONE" ############################### # Now use sidconf table... # create sidmaintconf unload file if [ "$1" = "" ]; then sidmaintconffile="sidmaintconf.unl" else sidmaintconffile="$1" fi if [ "$sidmaintconffile" = "-" ]; then sidmaintconffile="" fi echo "$0: sidmaintconffile=[$sidmaintconffile]" if [ "$2" = "" ]; then this_carrier="" else this_carrier="$2" fi echo "$0: this_carrier=[$this_carrier]" if [ "$3" = "" ]; then this_sidmaitntype="" else this_sidmainttype="$3" fi echo "$0: this_sidmainttype=[$this_sidmainttype]" if [ "$4" = "" -o "$5" = "" ]; then eval `rptdates tm sfd | awk '{print "SDATE=" $1 "; EDATE=" $2}` else SDATE="$4" EDATE="$5" fi echo "$0: SDATE=[$SDATE] EDATE=[$EDATE]" tmp1file="/tmp/$0_1_$$" tmp2file="/tmp/$0_2_$$" if [ -n "$DIREC_SITE" ]; then DIREC_SITE_BIT=" and dt.site = \"$DIREC_SITE\"" else DIREC_SITE_BIT="" fi # standard sidconf fields # recordno # sid, sidmainttype, sdate, edate, # grid, # directoryid, # serialnumber, # purchased, # manufacturer, # model, # supplier, # datatype, # carriercode, # servicetype, # dateupdated txsql -s -d catcom -F "|" >$tmp1file 2>$tmp2file <= "$SDATE") ) UNION select sidconf.recordno, sidconf.sid, sidconf.sidmainttype, sdate, edate, directoryid, sidconf.grid, datatype, serviceproviderdir, carriercode, grname1, grname3, "", "", manufacturer, model, servicetype, genfld4 from sidconf, importdatatype, outer (groupname, outer gnextra) where sidconf.directoryid is null and (sidconf.grid is not null and length(sidconf.grid) > 0) and sidconf.grid = groupname.grid and sidconf.grid = groupname.grid and groupname.grid = gnextra.grid and sidconf.datatype = importdatatype.importdatatypeid and ( (edate IS NULL and sdate <= "$EDATE") or (edate IS NOT NULL and sdate <= "$EDATE" and edate >= "$SDATE") ) UNION select sidconf.recordno, sidconf.sid, sidconf.sidmainttype, sdate, edate, directoryid, sidconf.grid, datatype, serviceproviderdir, carriercode, grname1, grname3, directcustom.surname, directcustom.firstname, manufacturer, model, servicetype, genfld4 from sidconf, importdatatype, outer (directtemplate, outer directcustom), outer (groupname, outer gnextra) where directoryid is not null and (sidconf.grid is not null and length(sidconf.grid) > 0) and sidconf.directoryid = directtemplate.recordno and directtemplate.recordno = directcustom.recordno and sidconf.grid = groupname.grid and groupname.grid = gnextra.grid and sidconf.datatype = importdatatype.importdatatypeid and ( (edate IS NULL and sdate <= "$EDATE") or (edate IS NOT NULL and sdate <= "$EDATE" and edate >= "$SDATE") ) UNION select sidconf.recordno, sidconf.sid, sidconf.sidmainttype, sdate, edate, directoryid, sidconf.grid, datatype, serviceproviderdir, carriercode, "", "", "", "", manufacturer, model, servicetype, genfld4 from sidconf, importdatatype where directoryid is null and (sidconf.grid is null or (sidconf.grid is not null and length(sidconf.grid) <= 0) ) and sidconf.datatype = importdatatype.importdatatypeid and ( (edate IS NULL and sdate <= "$EDATE") or (edate IS NOT NULL and sdate <= "$EDATE" and edate >= "$SDATE") ) order by 4 SQLCMD0 if grep -il rror "$tmp2file" >/dev/null then # error cat "$tmp2file" else cat "$tmp1file" | \ sed -e 's/,/\;/g;s/ */ /g;s/\|$//;s/\"/\\\"/g;s/ *\,/\,/g' | \ awk -F'|' \ -v"this_carrier=$this_carrier" \ -v"this_sidmainttype=$this_sidmainttype" \ -v"SDATE=$SDATE" -v"EDATE=$EDATE" ' { #print "\$0=[" $0 "]" if ( $1 == "Status:" ) { next } f = 0 recordno = $(++f) sid = $(++f) sidmainttype = $(++f) sdate = $(++f) edate = $(++f) directoryid = $(++f) grid = $(++f) datatype = $(++f) serviceproviderdir = $(++f) carriercode = $(++f) grname1 = $(++f) grname3 = $(++f) surname = $(++f) firstname = $(++f) manufacturer = $(++f) model = $(++f) servicetype = $(++f) genfld4 = $(++f) # only include this_carrier if ( this_carrier != "" && serviceproviderdir != this_carrier ) next # only include this_sidmainttype if ( this_sidmainttype != "" && sidmainttype != this_sidmainttype ) next if ( serviceproviderdir == "" ) serviceproviderdir = "UNKNOWN" "_" carriercode gsub("\t","",sid) gsub(" ","",sid) gsub("-","",sid) printf("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|\n", recordno, sid, sidmainttype, sdate, edate, directoryid, grid, datatype, serviceproviderdir, carriercode, grname1, grname3, surname, firstname, manufacturer, model, servicetype, genfld4) | "sort -u" }' > "$sidmaintconffile" fi rm -f "$tmp1file" rm -f "$tmp2file" exit 0