主程序
#!/bin/bash . /etc/ti/ti.conf . /etc/ti/ti.fun #cat YZXX/eg-1-basic.json | curl -H "Content-Type:application/json" -X POST -d @- http://address:port/project/REQUESTMAPPING # List all file in Workspace. # Create current output directory. [ -d ${OUTPUTDIR} ] && rm -fvr ${OUTPUTDIR} [ ! -d ${OUTPUTDIR} ] && mkdir -pv ${OUTPUTDIR} #getInterfaceName | tee ${LOGINFO}.log getInterfaceName
配置文件
#!/bin/bash # Input information. WORKSPACE=/opt/home/Curl-Workspace SUFFIX=".json" PROTOCOL="http://" URI="Address:Port/Project/" URL=${PROTOCOL}${URI} # Output information. LOGINFO=`date +%F_%H%M` RESULTOUTDIR=${LOGINFO} OUTPUTDIR=./${RESULTOUTDIR}
函数文件
#cat YZXX/eg-1-basic.json | curl -H "Content-Type:application/json" -X POST -d @- http://Address:Port/Project/RequestMappering # Input: Direcory # Output: SubDirectory traverseDirectoryFindFile() { ls -1 ${1} } getInterfaceName() { for d in $(traverseDirectoryFindFile ${WORKSPACE}) do # Traversing the directory. if [ -d ${WORKSPACE}/$d ]; then # Echo interface name. echo -e "#########################\n## Check Informations. ##\n#########################" echo -en "Interface: " echo $d # Get file name. getFilename fi done } getFilename() { # Get the file that named end with ".json". #for f in $(traverseDirectoryFindFile ${WORKSPACE}/${d}) for f in $(traverseDirectoryFindFile ${WORKSPACE}/${d} | grep "${SUFFIX}$") do echo -e "\tJson file: $f" FILE=${WORKSPACE}/${d}/${f} INTERFACE=${d} #echo -e "\tJson file name: "$FILE echo -e "\tInterfaceName: "$INTERFACE echo -e "\tURL: "$URL${INTERFACE} # Create subdirectories. CURDIR="" && CURDIR=${OUTPUTDIR}/${INTERFACE} CreateInfo=`mkdir -pv ${CURDIR}` echo -e "\t${CreateInfo}" RESFILE=${CURDIR}/${f}.txt #RESFILE=`echo ${RESFILE} | sed 's/.json/.txt'` echo -e "\tResult: ${RESFILE}" # Curl ... echo -e "\n****** Return ******" #cat $FILE | curl -H "Content-Type:application/json" -X POST -d @- $URL${INTERFACE} 2>/dev/null | tee ${RESFILE} cat $FILE | curl -# -H "Content-Type:application/json" -X POST -d @- $URL${INTERFACE} 2>/dev/null | tee ${RESFILE} echo -e "\n\n****** Over ******\n\n" done }
ti.