We are running containers on open shift platform. The application pods are running fine. We able to login to the pod using the below command
oc exec -it <podname> -- /bin/bash
also tried /bin/sh
once login we are trying to execute a script which is available in a particular folder (/opt/scripts)
When we run sh script it works. When we run script without sh it throws command not found
Inside the script we have #!bin/ksh (tried with bash and also sh)
How can I run the script without sh prefix
Update: Tried to simulate the scenario inside the container
Below are the installed shells inside the container
sh-4.4$ cat /etc/shells
/bin/sh
/bin/bash
/usr/bin/sh
/usr/bin/bash
This is a script. The first line is updated
sh-4.4$ more tRun
#!/bin/sh
Runs only with prefix sh or bash
sh-4.4$ tRun
sh: tRun: command not found
sh-4.4$ sh tRun
JAVA_HOME is not set. Unexpected results may occur.
Set JAVA_HOME to the directory of your local JDK to avoid this message.
Please enter aguments:
^C
sh-4.4$ bash tRun
JAVA_HOME is not set. Unexpected results may occur.
Set JAVA_HOME to the directory of your local JDK to avoid this message.
Please enter aguments:
^C
#!bin/kshshould likely be#! /bin/ksh -(the missing/is the most important missing part) or#! /bin/bash -or#! /bin/sh -if/bin/kshdoesn't exist in that container but/bin/bashor/bin/shdoes and the script doesn't use Korn-specific extensions not also found in bash/sh – Stéphane Chazelas Jun 27 '23 at 19:23