0

when I login the kubernetes v1.23 pod using this command:

exec kubectl exec -i -t -n reddwarf-storage reddwarf-postgresql-postgresql-0 -c reddwarf-postgresql -- sh -c "clear; (bash || ash || sh)"

show error:

sh: 1: clear: not found

I am using docker.io/bitnami/minideb:bullseye as the base image. why did this error happen? what should I do to avoid this problem?

1
  • try replacing clear with tput clear or printf '\33[H\33[2J'. clear (to clear the screen), though common is not a standard command. Commented Jul 28, 2022 at 7:31

2 Answers 2

3

try replacing clear with tput clear or printf '\33[H\33[J'. clear (to clear the screen), though common is not a standard command.

tput clear and printf are standard, the escape sequence to clear the screen may vary from terminal to terminal, tput clear would query the termcap or terminfo databases for the sequence for the terminal specified with the $TERM environment variable; with printf, here we hard code the sequence for DEC terminals (starting with the VT100 terminal from the late 70s) and as specified by ANSI X3.64 where \33[H takes the cursor to the home position, and \33[J clears til the end of the screen (leaving scrollback buffer and alternate screen, where supported, alone) which is recognised by most terminals and terminal emulators.

1

The simplest way to stop the error is to remove the clear command from the commands you use to log into your pods.

The next simplest way is to use the alternative screen clearing commands suggested in Stephane's answer.

The third simplest way is to update the requirements of which commands must be present in your organization's pods, and add the clear command to the list. Then update your build software's procedures to match the new requirements. From that point on new pods will include the clear command and the error will stop.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .