Why does my shell script gives the error: "declare: not found", when executed in ksh shell?

Solution Verified - Updated -

Issue

  • A shell script gives the error: "declare: not found", when executed in ksh shell.

    # echo $0
    ksh
    # ls -l /home/testksh/tmout.sh
    -rwxr-xr-x. 1 root root 22 Sep 26 20:01 /home/testksh/tmout.sh
    # cat /home/testksh/tmout.sh
    declare -rx TMOUT=900
    # /home/testksh/tmout.sh
    /home/testksh/tmout.sh[1]: declare: not found [No such file or directory]
    

Environment

  • Red Hat Enterprise Linux 9
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 5
  • ksh

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content