在shell脚本中,可以使用以下方法来检测它是否在Solaris系统中运行:
uname
命令:if [ "$(uname)" = "SunOS" ]; then
echo "This script is running on Solaris"
fi
/usr/bin/uname
命令:if [ "$(/usr/bin/uname)" = "SunOS" ]; then
echo "This script is running on Solaris"
fi
os=
系统变量:os=$(uname)
if [ "$os" = "SunOS" ]; then
echo "This script is running on Solaris"
fi
OSTYPE
环境变量:if [ "$OSTYPE" = "sunos" ]; then
echo "This script is running on Solaris"
fi
在这些方法中,可以使用任何一种来检测脚本是否在Solaris系统中运行。
领取专属 10元无门槛券
手把手带您无忧上云