Compare data with while if else loop ?!

Good midday and hello to everyone! =)

If I describe some things wrong please be aware, that english is not my native language!! :smiley:

I'm a bit stuck with a script I need to finish. Due to data protection I need to hide some paths but that should be no problem.

My script connects to a db2 database and pulls the information of "app_name" and "app_version". It then compares the two parameters with a directory. If some of the names and versions do not match or can't be found it needs to check if the untraceable data can be found in another file. The format I pull out of the database is like this: AAL;00.01-02; first the "app_name" and second the "app_version"

This is the part where I am stuck. Maybe i'm just to tired or I think way to complicated but I can't find a solution :confused:

function readdatabase() {
test -f /opt/XXXX/tc/conf/TC.conninfo || ftc_die "Datei nicht gefunden --> Abbruch"
  ftc_info "TC.conninfo einlesen"
  . /opt/XXXX/tc/conf/TC.conninfo && ftc_ok "Datei vorhanden --> Einlesen"
  ftc_info "Verbinde mit DB2 Datenbank"
  db2 connect to $CONN_DB user $CONN_USER using $CONN_PW || ftc_die "DB-Connect fehlgeschlagen"
  ftc_ok "DB-Connect erfolgreich"
  ftc_info "Hole app_name und app_version aus DB"
  db2 -x "select distinct trim(lower(app_name_ga)) || ';' || trim(app_version_ga) from tanc_gavR4" | \
  #sed -e 's|/modules_|;|;s|.properties||' > $FTC_TMPDIR/tanc_gav.tmp
  sed -e " /^$/ d" \
  > $FTC_TMPDIR/tanc_gav.tmp
  cd /opt/tomcat_xxx_1/webapps/xxx/app && \
  ls -d */modules_* | \
  sed -e 's|/modules_|;|;s|.properties||' > $FTC_TMPDIR/directory.tmp
  while read -r ZEILE ; do
     APP=${ZEILE/;*}
     VER=${ZEILE/*;}
     test -f /opt/tomcat_xxx_1/webapps/xxx/app/$APP/modules_$VER.properties || ftc_warning "$APP;$VER fehlt"
#   cat /var/servershare/scripts/templates/webanwendungen.dbin | sed -e 's|/modules_|;|;s|.properties||'
  done < $FTC_TMPDIR/tanc_gav.tmp
}

So my idea was to use a while if else statement and compare the modules that can't be find with the "webanwendungen.dbin" but I don't know how to do that.

If you need further information please let me know.

Thank you in advance!

Welcome to the forum.

Having read your verbal description thrice I'm not sure I understood your problem, and your function listing doesn't really help. Input / file data and / or directory structures / contents would have been beneficial, as would have some decent indentation of the code. Line continuation hitting comment lines won't work, I'm afraid.

Let me paraphrase what I found after having removed all the logging / messaging fuss:
Define the three "authentication variables" by sourcing file TC.conninfo .
Connect to DB.
Select app_name;app_version from DB, modify with some sed script into a temp file.
Create some other temp file from a certain, sed modified, directory listing never to be used.
Read and test first temp file's contents against some directory contents, print warning msg if missing.

What exactly doesn't work (the way you expect)? Post input data to analyse / work upon.