Yq: Using with scp to get stdout

Created on 16 Aug 2019  路  5Comments  路  Source: mikefarah/yq

I'm trying something, maybe it's not in the scope of the tool, it doesn't hurt to ask for help here. After running the below line:

scp [username]@[hostname]:~/.kube/config /dev/tty &> /dev/null | yq r - apiVersion

I'm getting this error, can I ask where I'm wrong?

main [ERRO] asked to process document index 0 but there are only 0 document(s)

Most helpful comment

try it without the /dev/tty bit ... I think it's currently copying the file there and not directing anything to stdout

alternatively, you can probably change /dev/tty to /dev/stdout

All 5 comments

the &> /dev/null before the pipe is redirecting both stdout and stderr to /dev/null, and so yq is getting an empty string as input

maybe you meant

scp [username]@[hostname]:~/.kube/config /dev/tty 2> /dev/null | yq r - apiVersion

?

@kmurphy4 you are right about stdout. I adjust the command to:

scp -q [username]@[hostname]:~/.kube/config /dev/tty 2> /dev/null | yq r - apiVersion

But yet not are running.

11:16:46 main [ERRO] asked to process document index 0 but there are only 0 document(s)

try it without the /dev/tty bit ... I think it's currently copying the file there and not directing anything to stdout

alternatively, you can probably change /dev/tty to /dev/stdout

Without /dev/tty not work. Take a look at the output just using /dev/tty:

$ brunowego@ally [~] scp -q [username]@[hostname]:~/.kube/config /dev/tty
apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: [secret]
    server: https://[hostname]:6443
  name: kubernetes
contexts:
- context:
    cluster: kubernetes
    user: kubernetes-admin
  name: kubernetes-admin@kubernetes
current-context: kubernetes-admin@kubernetes
kind: Config
preferences: {}
users:
- name: kubernetes-admin
  user:
    client-certificate-data: [secret]
    client-key-data: [secret]

@kmurphy4 works!

scp -q [username]@[hostname]:~/.kube/config /dev/stdout | yq r - apiVersion
Was this page helpful?
0 / 5 - 0 ratings

Related issues

infa-ddeore picture infa-ddeore  路  5Comments

OnkelTem picture OnkelTem  路  8Comments

jodh-intel picture jodh-intel  路  3Comments

cdaguerre picture cdaguerre  路  4Comments

jmreicha picture jmreicha  路  9Comments