Unable to set PATH through ksh shell

I'm trying to set path for the current session but it is not doing so.
It works perfectly on command line though.

#!/usr/bin/ksh

PATH=$PATH:/opt/quest/bin

Is there any specific way to set path on korn?

PATH is inherited by child processes from parent processes. Any processes you create after setting that path will get it.

Nothing else will. It doesn't propagate.

What exactly are you doing that does not work?

I'm trying to make the below script working.

#!/usr/bin/ksh

PATH=$PATH:/opt/quest/bin

But after running the script , the PATH still remains unchanged.

When you run it, it starts a new shell, changes PATH, and quits. The new shell dies immediately and takes the new PATH with it. PATH goes from parents to children, not vice versa, so it gets copied nowhere.

If you want to run the script in your own shell, source it. . ./scriptname That will set PATH in your own shell, not a new one.

1 Like