linux - Ambiguous redirect error : Remote execution of a command -


i trying execute command remotely. command works fine on local server. when run remotely, complains ambiguous redirection. please me fix same.

the command runs fine on local follows:

    echo '{"service": {"name": "$service", "port":443, "check":{"script":"curl '"$node_ip:443"' >/dev/null 2>&1","interval":"10s"}}}' | tee /etc/module/test.json 

i store above command in variable

    command="echo '{"service": {"name": "$service", "port":443, "check":{"script":"curl '"$node_ip:443"' >/dev/null 2>&1","interval":"10s"}}}' | tee /etc/module/test.json" 

and execute it:

    remoteexecute $remotehost $command 
  • remoteexecute function have written.

the quoting has problem.

command="echo '{"service": {"name": "$service", "port":443, "check":{"script":"curl '"$node_ip:443"' >/dev/null 2>&1","interval":"10s"}}}' | tee /etc/module/test.json" 

please try below one

command='echo '\''{"service": {"name": "$service", "port":443, "check":{"script":"curl '\''"$node_ip:443"'\'' >/dev/null 2>&1","interval":"10s"}}}'\'' | tee /etc/module/test.json' 

putting in script , echoing shows command variable holds wanted.

#!/bin/bash command='echo '\''{"service": {"name": "$service", "port":443, "check":{"script":"curl '\''"$node_ip:443"'\'' >/dev/null 2>&1","interval":"10s"}}}'\'' | tee /etc/module/test.json' echo "$command"  linux:~/tst> ./test.sh  echo '{"service": {"name": "$service", "port":443, "check":{"script":"curl '"$node_ip:443"' >/dev/null 2>&1","interval":"10s"}}}' | tee /etc/module/test.json 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -