Based on:
https://unix.stackexchange.com/questions/1459/remote-for-loop-over-ssh
I am trying to run a for loop command through oc rsh
but it fails with below error:
$ oc rsh my-app-10-lprki 'for i in /var/lib/*; do echo $i; done'
exec failed: container_linux.go:345: starting container process caused "exec: \"for i in /var/lib/*; do echo $i; done\": stat for i in /var/lib/*; do echo $i; done: no such file or directory"
command terminated with exit code 1
I have also tried without quotes, with double quotes but that also fails.
This works fine (without quotes):
$ oc rsh my-app-10-lprki ls -la /var/lib/
total 24
drwxr-xr-x. 1 root root 104 Nov 22 22:21 .
drwxr-xr-x. 1 root root 17 Sep 28 2017 ..
drwxr-xr-x. 2 root root 44 Sep 28 2017 alternatives
Any suggestions on how to run a for loop remotely through oc rsh
like (that currently fails):
oc rsh my-app-10-lprki 'for i in /var/lib/*; do echo $i; done'
?
Based on below suggestions I have also tried:
$ oc rsh my-app-10-lprki -- /bin/sh -c 'for i in `ls /var/lib`; do echo $i; done'
exec failed: container_linux.go:345: starting container process caused "exec: \"--\": executable file not found in $PATH"
command terminated with exit code 1
and:
$ oc rsh my-app-10-lprki -- /bin/bash -c 'for i in `ls /var/lib`; do echo $i; done'
exec failed: container_linux.go:345: starting container process caused "exec: \"--\": executable file not found in $PATH"
command terminated with exit code 1
and:
$ oc rsh my-app-10-lprki -- /usr/bin/bash -c 'for i in `ls /var/lib`; do echo $i; done'
exec failed: container_linux.go:345: starting container process caused "exec: \"--\": executable file not found in $PATH"
command terminated with exit code 1
Where:
$ oc rsh my-app-10-lprki which bash
/usr/bin/bash