OS/Linux

version html 생성 shell Script

아르비스 2016. 7. 1. 13:27

version file 정보 찾는게 힘들어서

폴더내 file을 읽어서 version 정보를 html 파일로 만드는 script를 생성함


# vi make_version.sh


#!/bin/sh


fileName=index.html

current_time=$(date "+%Y%m%d-%H%M%S")

title="This is Current Version Infomation for STG Server!! [$current_time]"

DIRS=`ls -l . | egrep '^d' | awk '{print $8}'`


echo "Start to make version.html file"


# for HTML

echo "<!DOCTYPE html>" > ${fileName}

echo "<html>" >> ${fileName}

echo "<head>" >> ${fileName}

echo "<meta charset=\"utf8\">" >> ${fileName}

echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">" >> ${fileName}

echo "<title>Current Version Info for STG Server</title>" >> ${fileName}

echo "</head>" >> ${fileName}

echo "<body>" >> ${fileName}

echo "<p><font size=\"3\">$title</font><p><p>" >> ${fileName}


# display Directory version Files

for DIR in $DIRS

do

  echo "<p> [ ${DIR} ]" >> ${fileName}

  echo "<pre>" >> ${fileName}

  while read line

  do

    echo "$line" >> ${fileName}

  done < ${DIR}/version.dat

  echo "</pre>" >> ${fileName}

  echo "<p>" >> ${fileName}

  echo "<hr>" >> ${fileName}

done


# html END

echo "</body>" >> ${fileName}

echo "</html>" >> ${fileName}


echo "Finished to make version.html file!!"