原因是.sh脚本在windows系统下用记事本文件编写的。不同系统的编码格式引起的。
转行文件的编码格式:
1、确保用户对文件有读写及执行权限
oracle@linux-106:~/RMAN/bin> chmod a+x test.sh
2、然后修改文件格式
(1)使用vi工具
> vi test.sh
(2)利用如下命令查看文件格式
:set ff 或 :set fileformat
可以看到如下信息
fileformat=dos 或 fileformat=unix
(3) 利用如下命令修改文件格式
:set ff=unix 或 :set fileformat=unix
:wq (存盘退出)
3、最后再执行
oracle@linux-106:~/RMAN/bin> ./test.sh
获取当前网站所指向IP的shell
#!/bin/sh
#
if [ "$1" = "" ]
then
echo "Usage: sh test.sh domainname"
exit
fi
dm="$1"
res=`/usr/bin/dig +noadditional +noauthority +noquestion +nocmd +nocomments @8.8.8.8 A $dm| grep $dm`
#echo "$res"
ip=`echo $res | awk '{print $5}'`
type=`echo $res | awk '{print $4}'`
if [ $type = 'CNAME' ]
then
res=`/usr/bin/dig +noadditional +noauthority +noquestion +nocmd +nocomments @8.8.8.8 A $ip| grep $ip`
ip=`echo $res | awk '{print $5}'`
fi
echo "$ip"