问题:linux中的shell脚本,如何改写为bat文件? 20

#!/bin/shif[$#-ne1];thenecho1>&2Usage:$0[config_file]exit127fiSOURCE=`awk-F"="'/^data... #!/bin/sh

if [ $# -ne 1 ]; then
echo 1>&2 Usage: $0 [config_file]
exit 127
fi

SOURCE=`awk -F"=" '/^database_name/ { print $2 }' $1`
SECONDS=`date +%s`
TARGET=$SOURCE"_"$SECONDS
DESTINATION=../$SOURCE.$DIALOG.$VERSION

echo Database: $SOURCE
echo Dialog ID: $DIALOG

#drop the target databse
psql -c "drop database $TARGET"

#create database objects
psql $TARGET < postgres_create.sql

#copy base tables
psql -c "copy (select * from message) to stdout" $SOURCE | psql -c "copy message from stdin" $TARGET

$TARGET
psql -c "copy (select * from qs_publicationstatustype) to stdout" $SOURCE | psql -c "copy qs_publicationstatustype from

stdin" $TARGET

#save the dialog
psql -c "copy (select * from q_dialog where q_dialog_id = $DIALOG) to stdout" $SOURCE | psql -c "copy q_dialog from stdin"

$TARGET

#create database objects
psql $TARGET < postgres_index.sql

#make the destination directory
mkdir -p $DESTINATION
mkdir -p $DESTINATION/cdd
mkdir -p $DESTINATION/corticon

#create readme files
echo "Note: Rules assets are owned by a different user and will have to be copied separately" >> $DESTINATION/cdd/README
echo "Note: Rules assets are owned by a different user and will have to be copied separately" >>

$DESTINATION/corticon/README

#export the database
pg_dump $TARGET > $DESTINATION/postgres_create.sql

#copy the import template to the destination
cp $TEMPLATE $DESTINATION/dialogsImport.sh
chmod +x $DESTINATION/dialogsImport.sh

#drop the temp database
psql -c "drop database $TARGET"

#append to the import config file
echo "database_name=$SOURCE" >> $DESTINATION/import.cfg

#append to the import README file

echo "*********************************************" >> $DESTINATION/README
echo "*" >> $DESTINATION/README
echo "* Program: dialogsImport" >> $DESTINATION/README
echo "*" >> $DESTINATION/README
echo "* Version 0.5" >> $DESTINATION/README
echo "*" >> $DESTINATION/README
echo "* Author: Dan Dreon" >> $DESTINATION/README
echo "*" >> $DESTINATION/README
echo "*********************************************" >> $DESTINATION/README

echo "* run this script as the database user - typically postgres" >> $DESTINATION/README
echo "* run this script from inside the dialogsImport folder" >> $DESTINATION/README
echo "* psql must be in your path" >> $DESTINATION/README
echo "* first edit the import.cfg script and enter the appropriate values" >> $DESTINATION/README
echo "* to run this script type ./dialogsImport import.cfg" >> $DESTINATION/README
echo "* Note: rules assets need to be copied separately" >> $DESTINATION/README

#archive the directory
tar -zcvf $DESTINATION.tar.gz $DESTINATION

#delete the original
rm -rf $DESTINATION

如何把这个shell脚本移植到windows 的bat中?各位大虾们,小弟现在有个棘手的问题,请大虾们给以帮助。
展开
 我来答
cnbubble
2011-07-22 · TA获得超过2606个赞
知道大有可为答主
回答量:1990
采纳率:83%
帮助的人:744万
展开全部
还有 “psql ”这样的命令?!,Windows里面没有可以实现这种功能的命令啊,估计自己写也没那么容易写出来啊!
要是一些简单的Shell ,改用Bat来写没有问题,这个有点高级啊! 我感觉 写不了,你还是死了这条心吧!
ma_er_dai_fu
2011-07-15 · 超过21用户采纳过TA的回答
知道答主
回答量:71
采纳率:0%
帮助的人:56万
展开全部
awk在windows下实现不了
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
ffihy
2011-07-15 · TA获得超过133个赞
知道答主
回答量:118
采纳率:0%
帮助的人:82.3万
展开全部
- -!
有人拿linux的shell和windows的bat比。。。。
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
暗X点
2011-07-14 · 超过15用户采纳过TA的回答
知道答主
回答量:105
采纳率:0%
帮助的人:44.7万
展开全部
bat是Windows的,你写的这些是Linux的命令。
追问
是 ,我想 写成bat的 该如何去写
追答
不行的,你这些命令是Linux下的,在windows 下是用不了的
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式