简体   繁体   中英

Running jq on a remote machine over ssh and overwrite the file

I am trying to create a file from the output of jq command over ssh command.

ssh <server-Name> "jq '.credsStore = "ecr-login"' ~/.docker/config.json > ~/.docker/output.json "

It gives me following error:

bash: .docker/output.json: No such file or directory

Am I not running the command properly or is there any other problem?

ssh "$server" "bash -s" <<'EOF'
[[ -e ~/.docker/config.json ]] || {
  echo "ERROR: $HOME/.docker/config.json does not exist on the remote server" >&2
  exit 1
}

jq '.credsStore = "ecr-login"' \
  <~/.docker/config.json \
  >~/.docker/output.json 
EOF

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM