Shell脚本新手在这里。只是想在我的shell脚本上输入一些内容。如果某个特定的目录存在,我基本上想从shell脚本启动一个perl脚本。unix编程逻辑检查目录
我的逻辑声音?我的支票好吗?
if [ $# != 2 ]; then
echo "USAGE: ./mytest.sh <host> <name>" 2>&1
echo " ./mytest.sh foo101.test.in foo" 2>&1
exit 1
fi
#Directories
DIRDATE=`date '+%Y%m%d'`
BASE=/dumps
STGDIR=$BASE/temp/$DIRDATE
#Check if directory exists
if [ -d "$STGDIR" ] then
echo "$STGDIR directory exists!"
perl foobar.pl -n $1 -d $STGDIR/ -s $2
else
echo "$STGDIR directory not found! Create the directory"
mkdir $STGDIR || { echo 'mkdir command failed' ; exit 1;}
if [ -d "STGDIR" ] then
echo "$STGDIR directory exists!"
perl foobar.pl -n $1 -d $STGDIR/ -s $2
fi
SO并不意味着成为分布式测试平台。你应该在本地测试你的脚本,尝试所有各种各样的角落案例,如果遇到了一个你无法解决的问题,那么* *会提出一个很好的问题。 – SiegeX 2011-03-31 04:22:18
在http://codereview.stackexchange.com上可能会得到更多答案 – 2011-03-31 12:27:50