The error "commnd not found" occurs when the oc exec command is executed and multiple commands separated by the pipe are sent to the pod in OCP

Solution Verified - Updated -

Environment

  • OpenShift Container Platform4

Issue

The following error occurs when the oc exec command is executed and multiple commands separated by the pipe are sent to the pod in OCP.

 $ oc -n openshift-ingress exec -it  router-default-65846695f8-4xzcw -- bash -c echo "show info" | socat stdio unix-connect:/var/lib/haproxy/run/haproxy.sock
zsh: socat: command not found...

Resolution

Using the '' or "" symbol for multiple commands,when the oc exec command is executed and multiple commands separated by the pipe are sent to the pod in OCP.

$ oc rsh router-default-65846695f8-4xzcw bash -c 'echo "show info" | socat stdio unix-connect:/var/lib/haproxy/run/haproxy.sock'

Root Cause

The multiple commands which separated by the pipe cannot be recognized and interpreted properly in the pod if not add the '' or "" symbol.

Diagnostic Steps

$ oc exec -it  router-default-65846695f8-4xzcw -- bash -c echo "show info" | socat stdio unix-connect:/var/lib/haproxy/run/haproxy.sock
socat: command not found...

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments