#!/bin/bash scriptdir=/var/script for i in `ls $scriptdir` do filetype=`echo ${i##*.}` if [ "$filetype" == "sh" ];then timeout 20 sh $scriptdir/$i |grep -v "^#"|grep "{"|awk -v "server=`hostname`" -v "file=$i" -F"{" '{print $1"{hostname=\""server"\",scriptname=\""file"\","$2}' fi done