【发布时间】:2017-06-28 18:26:37
【问题描述】:
我正在尝试创建一个脚本来在我的 CentOS 7 最小的虚拟机上创建虚拟集群。
我有一个名为cluster的脚本
#!/bin/bash
function vc
{
echo
echo -n "Enter project name: "
read platform_name
echo
echo -n "web extension: "
read web_extension
echo
echo -e "The following website will be created"
echo -e "\e[32m Platform:\e[0m\t${platform_name}"
echo -e "\e[32m Extension:\e[0m\t${web_extension}"
echo -e "\e[32m Full URL:\e[0m\t http://www.${platform_name}.${web_extension}"
echo
echo -e "Do you wish to proceed? [Y/n]"
read -p "Are you sure? " -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo
echo -e "\e[32m Creating platform \e[0m\t"
else
echo
echo -e "\e[32m Not creating platform \e[0m\t"
fi
}
if [ -n "$(type -t $FUNCTION_NAME)" ] && [ "$(type -t $FUNCTION_NAME)" =
function ];
then $FUNCTION_NAME $2; else help; fi
然后据我了解,我只需要使其可执行
chmod +x cluster
在此之后我应该为它创建一个系统链接ln -s cluster /bin/cluster
现在我通常应该能够在终端中输入 cluster vc 并且它应该执行脚本但它一直给我“找不到命令集群”
我做错了什么吗?还是我需要在其上使用另一个 chmod 才能运行它?
【问题讨论】: