Undefined variable error in csh script

I have one function in csh script, and in this function I use one variable, which is obtained from one file. But when using a script, an undefined error is thrown for it for the same variable. I am using Linux.

My code

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 } 

The following is the error:

 function: Command not found. {: Command not found. SSH_FOR_RCOMMANDS: Undefined variable. 

Please suggest what am I missing?

0
source share
1 answer

C Shell csh has no functions. He has pseudonyms, but they are harder to write and read. For an example, see here: https://unix.stackexchange.com/questions/62032/error-converting-a-bash-function-to-a-csh-alias

It might be a good idea to just switch to Bash, where your existing code can already work.

+1
source

Source: https://habr.com/ru/post/1210529/


All Articles