Quantcast
Channel: Liquibase Forums
Viewing all articles
Browse latest Browse all 2993

executeCommand bash script echo show only after the script is complete

$
0
0
We have a custom script that log it progress so we can track where it is.
All the echo are show in the terminal only after the script complete it execution.

here si the changelog

<changeSet id="changesetID" author="user">
    <executeCommand executable="${project.build.directory}/classes/changelogs/init/scriptMySql" os="Linux">
      <arg value="someparam"/>
    </executeCommand>
  </changeSet>

here is the logic of the bash script.

#!/bin/bash

nbFile=0
for SQLFile in ${1}/*.sql; do
  nbFile=$((nbFile+1))
done

noFile=1
for SQLFile in ${1}/*.sql; do
  percent=$(printf '%i %i' $noFile $nbFile | awk '{ pc=100*$1/$2; i=int(pc); print (pc-i<0.5)?i:i+1 }')
  echo "File to manage : $SQLFile ($noFile / $nbFile --> $percent%)"

  // manage the file in the folder. 

  noFile=$((noFile+1))
done
echo "end"

So when we do the script we expect that it log each time it start a new file but the log all append after the execution.

Viewing all articles
Browse latest Browse all 2993

Trending Articles