#!/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中?各位大虾们,小弟现在有个棘手的问题,请大虾们给以帮助。
是 ,我想 写成bat的 该如何去写
追答不行的,你这些命令是Linux下的,在windows 下是用不了的