问题: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中?各位大虾们,小弟现在有个棘手的问题,请大虾们给以帮助。 展开
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中?各位大虾们,小弟现在有个棘手的问题,请大虾们给以帮助。 展开
4个回答
展开全部
awk在windows下实现不了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
- -!
有人拿linux的shell和windows的bat比。。。。
有人拿linux的shell和windows的bat比。。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
bat是Windows的,你写的这些是Linux的命令。
追问
是 ,我想 写成bat的 该如何去写
追答
不行的,你这些命令是Linux下的,在windows 下是用不了的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |