
누구든지 이 쉘 스크립트를 bash 스크립트 pl로 변환하여 나를 도와줄 수 있습니까?
내 쉘 스크립트는 다음과 같습니다
#!/bin/bash
IN="ifa_in_B2C=ifa_inB2C;ifa_in_ERP_Soap=ifa_inERP;sm=sm_main;tp=tp_main;trp=trp_main;usr=usr_main;wl=wl_main;pe_notification_email=pe_email;pe_notification_sms=pe_sms;pe_group_calc=pe_group;ifa_out_sms=ifa_outSMS;ifa_out_email=ifa_outEmail;ifa_out_oxiB2C=ifa_outOxi;ifa_out_OMTS=ifa_outOMTS;log=log_main;sys=sys_main;ifa_sys=ifa_sys;sm_sys=sm_sys;sp=sp_main;usr_sys=usr_sys;cache_reload=cache_reload"
export GOPATH=C:/Users/user/Desktop/nxtxn-b2c
export PATH=$PATH:C:/Users/user/Desktop/nxtxn-b2c/srcC:/Users/user/Documents/nxtxn-b2c/src:C:/Go/bin
arr=$(echo $IN | tr ";" "\n")
echo "No of Arguments Passed is "$#
if [ "$#" -gt "2" ] || [ "$#" == "2" ]; then
DATE=`date +%Y-%m-%d:%H:%M:%S`
BUILD_ARG=""
echo $DATE
if [ "$3" == "buildversion" ]; then
echo "ENTER the Version no"
read VERSION_NO
echo "ENTER Version Description"
read VERSION_DESP
if [ "$VERSION_NO" == "" ]; then
$BUILD_ARG=""
else
TEMP="\"-X main.version $VERSION_NO -X main.version_date $DATE -X main.version_desc $VERSION_DESP\""
echo $TEMP
BUILD_ARG="-ldflags "
BUILD_ARG=$BUILD_ARG$TEMP
fi
else
echo "Wrong 3rd argument: Use buildversion to create version tags"
fi
echo "Build Arguments : "$BUILD_ARG
echo "METHOD:$1 SUBSYS:$2"
echo "GOPATH : $GOPATH"
for subsys in $arr
do
IFS='=' read -a arr_tmp <<< "$subsys"
echo "%%%%%%%%%%%%%%%%%%%%%%%%% START %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
echo "SUBSYS: ${arr_tmp[0]}"
subsys_pkg=${arr_tmp[0]}"_pkg"
echo "$subsys_pkg"
subsys_main=${arr_tmp[0]}"_main"
if [[ ${arr_tmp[0]} != pe* ]] ; then
main_path="$GOPATH/src/${arr_tmp[0]}/$subsys_main"
else
main_path="$GOPATH/src/pe/${arr_tmp[0]}/$subsys_main"
fi
if [[ ${arr_tmp[0]} != pe* ]] ; then
cd "$GOPATH/src/${arr_tmp[0]}/$subsys_pkg"
else
cd "$GOPATH/src/pe/${arr_tmp[0]}/$subsys_pkg"
fi
if [ "$1" == "build" ]; then
if [ "$2" == "all" ]; then
cd $main_path
echo "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
eval go install -v -x $BUILD_ARG
ret_cmd=$?
error_msg="ERROR : Failed to run the build command!"
if [ $ret_cmd != 0 ]; then
echo "$error_msg"
exit;
fi
mv $GOPATH/bin/${arr_tmp[0]}"_main" $GOPATH/bin/${arr_tmp[1]}
echo "BUILT and INSTALLED : ${arr_tmp[0]}"
elif [ "$2" == ${arr_tmp[0]} ]; then
cd $main_path
echo "***********%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%***********"
eval go install -v -x $BUILD_ARG
ret_cmd=$?
error_msg="ERROR : Failed to run the build command!"
if [ $ret_cmd != 0 ]; then
echo "$error_msg"
exit;
fi
mv $GOPATH/bin/${arr_tmp[0]}"_main" $GOPATH/bin/${arr_tmp[1]}
echo "BUILT and INSTALLED : ${arr_tmp[0]}"
break
78,1-8 40%
fi
elif [ $1 == "cleanbuild" ]; then
if [ $2 == "all" ]; then
echo "********************** CLEAN ***************************"
cd $main_path
go clean -i -x
echo "****************************************************************"
eval go install -v -x $BUILD_ARG
ret_cmd=$?
error_msg="ERROR : Failed to run the build command!"
if [ $ret_cmd != 0 ]; then
echo "$error_msg"
exit;
fi
mv $GOPATH/bin/${arr_tmp[0]}"_main" $GOPATH/bin/${arr_tmp[1]}
#eval go install -v -x $BUILD_ARG
echo "CLEANED and INSTALLED : ${arr_tmp[0]}"
elif [ $2 == ${arr_tmp[0]} ]; then
echo "********************** CLEAN ***************************"
cd $main_path
go clean -i -x
echo "%%%%%%%*************************************************%%%%%%%%"
# eval go build -v -x $BUILD_ARG
eval go install -v -x $BUILD_ARG
ret_cmd=$?
error_msg="ERROR : Failed to run the build command!"
if [ $ret_cmd != 0 ]; then
echo "$error_msg"
exit;
fi
mv $GOPATH/bin/${arr_tmp[0]}"_main" $GOPATH/bin/${arr_tmp[1]}
echo "CLEANED and INSTALLED : ${arr_tmp[0]}"
break
fi
elif [ $1 == "clean" ]; then
if [ $2 == "all" ]; then
echo "********************** CLEAN ONLY ***************************"
cd $main_path
go clean -i -x
echo "****************************************************************"
echo "CLEANED : $subsys"
elif [ $2 == ${arr_tmp[0]} ]; then
echo "********************** CLEAN ***************************"
cd $main_path
go clean -i -x
echo "%%%%%%%*************************************************%%%%%%%%"
echo "CLEANED and INSTALLED : $subsys"
break
fi
else
echo "wrong first argument. Use build|cleanbuild"
break
fi
done
else
echo "Wrong number of arguments. Use build|cleanbuild with subsystem to build"
fi
답변1
Windows의 Bash 스크립트
전체 유닉스 스타일 하위 시스템이 설치된 경우에만 Windows에서 이를 실행할 수 있습니다. 스크립트는 date
및 같은 표준 Unix 스타일 유틸리티가 tr
설치되고 정규화되지 않은 명령을 사용하여 실행될 것으로 예상합니다 date
.
부주의한 컷 앤 페이스트
라인
78,1-8 40%
파일을 복사하거나 전송하는 대신 편집기(vim?)에서 이 스크립트를 부주의하게 잘라내어 붙여넣은 것 같습니다. 이 줄은 삭제되어야 합니다.
잘못된 구문
라인
export PATH=$PATH:C:/Users/user/Desktop/nxtxn-b2c/srcC:/Users/user/Documents/nxtxn-b2c/src:C:/Go/bin
여러 가지 오류가 포함되어 있습니다
- $PATH 요소에서는 콜론을 이스케이프 처리하지 않고 사용할 수 없습니다. 콜론은 구분 기호이기 때문입니다.
...b2c/src
와 사이에는 콜론이 있어야 합니다 .C:/Users