我在csh脚本中有一个函数,在这个函数中我使用的是一个源自一个文件的变量。但是在使用脚本时,它会为同一个变量抛出未定义的错误。 我正在使用Linux。
我的代码
function init_remote_commands_to_use
{
# Test if the environment variable SSH_FOR_RCOMMANDS is present in .temip_config file,
# use secured on non secured rcommand depending on the result
if [ "$SSH_FOR_RCOMMANDS" != "" ]
then
if [ "$SSH_FOR_RCOMMANDS" = "ON" ]
then
# Check if the environment variable SSH_PATH is specified in .temip_config file
if [ "$SSH_PATH" != "" ]
then
SH_RCMD=$SSH_PATH
else
SH_RCMD=$SSH_CMD
fi
# Check if a ssh-agent is already running
if [ "$SSH_AGENT_PID" = "" ]
then
#Run ssh-agent for secured RCommands
eval `ssh-agent`
ssh-add
STARTEDBYME=YES
fi
else
if [ "$SSH_FOR_RCOMMANDS" = "OFF" ]
then
SH_RCMD=$RSH_CMD
else
echo "Please set the SSH_FOR_RCOMMANDS value to ON or OFF in the .temip_config file"
exit 1
fi
fi
else
SH_RCMD=$RSH_CMD
fi
}
以下是错误:
function: Command not found.
{: Command not found.
SSH_FOR_RCOMMANDS: Undefined variable.
请有人建议我缺少什么?
答案 0 :(得分:1)
C Shell csh
没有功能。它确实有别名,但是那些更难写和读。例如,请参见此处:https://unix.stackexchange.com/questions/62032/error-converting-a-bash-function-to-a-csh-alias
简单地切换到Bash可能是一个好主意,现有代码可能已在其中工作。