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 -

reflection - How to access the object-members of an object declaration in kotlin -

php - Doctrine Query Builder Error on Join: [Syntax Error] line 0, col 87: Error: Expected Literal, got 'JOIN' -