当前位置: 技术问答>linux和unix
shell转换成dos
来源: 互联网 发布时间:2016-06-04
本文导语: 如题,小弟对shell一窍不通,哪位高手能帮我把下面的shell处理转换成dos处理?谢谢! REBUILD_LIST=$1 USERNAME=$2 USERPASS=$3 EXEC_LOG="./index_rebuild_${REBUILD_LIST}_`date +%y%m%d_%H%M%S`.log" if [ ! -f ${REBUILD_LIST} ] then echo "****** E...
如题,小弟对shell一窍不通,哪位高手能帮我把下面的shell处理转换成dos处理?谢谢!
REBUILD_LIST=$1
USERNAME=$2
USERPASS=$3
EXEC_LOG="./index_rebuild_${REBUILD_LIST}_`date +%y%m%d_%H%M%S`.log"
if [ ! -f ${REBUILD_LIST} ]
then
echo "****** Error!! Not Index Rebuild list file. ******"
echo "****** Error!! Not Index Rebuild list file. ******" >>
${EXEC_LOG}
exit 99
fi
if [ -z ${USERNAME} ]
then
echo "****** Error!! Oracle username is null!! ******"
echo "****** Error!! Oracle username is null!! ******" >> ${EXEC_LOG}
exit 99
fi
if [ -z ${USERPASS} ]
then
echo "****** Error!! Oracle userpassword is null!! ******"
echo "****** Error!! Oracle userpassword is null!! ******" >>
${EXEC_LOG}
exit 99
fi
cat ${REBUILD_LIST} | while read LIST_NAME
do
INDEX_NAME=${LIST_NAME%%:*}
PARTITION_NAME=${LIST_NAME##*:}
if [ ${INDEX_NAME} = ${PARTITION_NAME} ]
then
PARTITION_NAME=""
fi
if [ -z ${PARTITION_NAME} ]
then
echo "****** [${INDEX_NAME}] Rebuild start `date +%y%m%d_%H%M%S`
******"
echo "****** [${INDEX_NAME}] Rebuild start `date +%y%m%d_%H%M%S`
******" >> ${EXEC_LOG}
sqlplus -L ${USERNAME}/${USERPASS} @index_rebuild.sql ${INDEX_NAME}
>> ${EXEC_LOG}
STS=$?
if [ ${STS} = 0 ]
then
echo "****** [${INDEX_NAME}] Index Rebuild COMPLETE!! `date
+%y%m%d_%H%M%S` ******"
echo "****** [${INDEX_NAME}] Index Rebuild COMPLETE!! `date
+%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
else
echo "****** Error!! [${INDEX_NAME}] Index Rebuild ERROR!!
`date +%y%m%d_%H%M%S` ******"
echo "****** Error!! [${INDEX_NAME}] Index Rebuild ERROR!!
`date +%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
# exit 99
fi
else
echo "****** [${INDEX_NAME}:${PARTITION_NAME}] Rebuild start `date
+%y%m%d_%H%M%S` ******"
echo "****** [${INDEX_NAME}:${PARTITION_NAME}] Rebuild start `date
+%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
sqlplus -L ${USERNAME}/${USERPASS} @index_rebuild_partition.sql
${INDEX_NAME} ${PARTITION_NAME} >> ${EXEC_LOG}
STS=$?
if [ ${STS} = 0 ]
then
echo "****** [${INDEX_NAME}:${PARTITION_NAME}] Index Rebuild
COMPLETE!! `date +%y%m%d_%H%M%S` ******"
echo "****** [${INDEX_NAME}:${PARTITION_NAME}] Index Rebuild
COMPLETE!! `date +%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
else
echo "****** Error!! [${INDEX_NAME}:${PARTITION_NAME}] Index
Rebuild ERROR!! `date +%y%m%d_%H%M%S` ******"
echo "****** Error!! [${INDEX_NAME}:${PARTITION_NAME}] Index
Rebuild ERROR!! `date +%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
exit 99
fi
fi
done;
exit 0
REBUILD_LIST=$1
USERNAME=$2
USERPASS=$3
EXEC_LOG="./index_rebuild_${REBUILD_LIST}_`date +%y%m%d_%H%M%S`.log"
if [ ! -f ${REBUILD_LIST} ]
then
echo "****** Error!! Not Index Rebuild list file. ******"
echo "****** Error!! Not Index Rebuild list file. ******" >>
${EXEC_LOG}
exit 99
fi
if [ -z ${USERNAME} ]
then
echo "****** Error!! Oracle username is null!! ******"
echo "****** Error!! Oracle username is null!! ******" >> ${EXEC_LOG}
exit 99
fi
if [ -z ${USERPASS} ]
then
echo "****** Error!! Oracle userpassword is null!! ******"
echo "****** Error!! Oracle userpassword is null!! ******" >>
${EXEC_LOG}
exit 99
fi
cat ${REBUILD_LIST} | while read LIST_NAME
do
INDEX_NAME=${LIST_NAME%%:*}
PARTITION_NAME=${LIST_NAME##*:}
if [ ${INDEX_NAME} = ${PARTITION_NAME} ]
then
PARTITION_NAME=""
fi
if [ -z ${PARTITION_NAME} ]
then
echo "****** [${INDEX_NAME}] Rebuild start `date +%y%m%d_%H%M%S`
******"
echo "****** [${INDEX_NAME}] Rebuild start `date +%y%m%d_%H%M%S`
******" >> ${EXEC_LOG}
sqlplus -L ${USERNAME}/${USERPASS} @index_rebuild.sql ${INDEX_NAME}
>> ${EXEC_LOG}
STS=$?
if [ ${STS} = 0 ]
then
echo "****** [${INDEX_NAME}] Index Rebuild COMPLETE!! `date
+%y%m%d_%H%M%S` ******"
echo "****** [${INDEX_NAME}] Index Rebuild COMPLETE!! `date
+%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
else
echo "****** Error!! [${INDEX_NAME}] Index Rebuild ERROR!!
`date +%y%m%d_%H%M%S` ******"
echo "****** Error!! [${INDEX_NAME}] Index Rebuild ERROR!!
`date +%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
# exit 99
fi
else
echo "****** [${INDEX_NAME}:${PARTITION_NAME}] Rebuild start `date
+%y%m%d_%H%M%S` ******"
echo "****** [${INDEX_NAME}:${PARTITION_NAME}] Rebuild start `date
+%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
sqlplus -L ${USERNAME}/${USERPASS} @index_rebuild_partition.sql
${INDEX_NAME} ${PARTITION_NAME} >> ${EXEC_LOG}
STS=$?
if [ ${STS} = 0 ]
then
echo "****** [${INDEX_NAME}:${PARTITION_NAME}] Index Rebuild
COMPLETE!! `date +%y%m%d_%H%M%S` ******"
echo "****** [${INDEX_NAME}:${PARTITION_NAME}] Index Rebuild
COMPLETE!! `date +%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
else
echo "****** Error!! [${INDEX_NAME}:${PARTITION_NAME}] Index
Rebuild ERROR!! `date +%y%m%d_%H%M%S` ******"
echo "****** Error!! [${INDEX_NAME}:${PARTITION_NAME}] Index
Rebuild ERROR!! `date +%y%m%d_%H%M%S` ******" >> ${EXEC_LOG}
exit 99
fi
fi
done;
exit 0
|
shell功能很强大的,dos的批处理功能很弱
搞不成的
if [ ! -f ${REBUILD_LIST} ]
是测试文件是否存在,dos下可以用exist
-z 是测试串长度是否为空,可以用==来判断和空串是否相同
INDEX_NAME=${LIST_NAME%%:*} 删除结尾的:*部分
PARTITION_NAME=${LIST_NAME##*:} 删除开头的*:部分
这两句是对字符串进行处理,dos就搞不定了
你自己根据需要自己写下dos下的批处理吧
实在不行,在windows下安装一个cygwin这样的东西就可以直接执行脚本了
搞不成的
if [ ! -f ${REBUILD_LIST} ]
是测试文件是否存在,dos下可以用exist
-z 是测试串长度是否为空,可以用==来判断和空串是否相同
INDEX_NAME=${LIST_NAME%%:*} 删除结尾的:*部分
PARTITION_NAME=${LIST_NAME##*:} 删除开头的*:部分
这两句是对字符串进行处理,dos就搞不定了
你自己根据需要自己写下dos下的批处理吧
实在不行,在windows下安装一个cygwin这样的东西就可以直接执行脚本了
|
最好的方式就是在 windows 下安装一个 cygwin,然后来执行 shell 脚本
|
lz,看来只能给你一些linux对应的windows命令了。。。抱歉。。。
|
如果是这样的话,还不如装个windows下的bash,我的空间就有得下载