Kevin Alder kindly put me straight on which shell was which and which shell was the default for QP2TERM so we all learned something that day. Previously I had been looking at how to set up the key functions in ksh as part of another test I was doing so I felt that this should be something that would fit nicely into the .profile file used for setting up the environment by user.
The answer came from a post on another site where the user was trying to find out if the request was a batch or interactive request. They used the tty -s function to determine type of request that had caused the terminal to be launched. From there we can sense if this is a SSH terminal or if it is being run from QP2TERM (needed to experiment to confirm the difference as I was not sure at the time) and set the shell accordingly. Kevin did mention using exec as the launch method for the shell as it would reduce the number of jobs on the system so I took that as being a good option.
Before you set up your .profile file you need to make sure your user profile is set up correctly. By default a profile is set to have a directly of ‘/home/*USRPRF’ where *USRPRF is the profile used. In my case that would be ‘/home/CHRISH” (note the upper case). When a profile is created it does not automatically create this directory for you so you would need to create it before creating the .profile file. I tend to create a lowercase path such as ‘/home/chrish’ and change the HOMEDIR setting for the profile to reflect that.
The following is the content of the file I created in my home directory, make sure you set the CCSID of the file to 819 (ASCII) and the content is ASCII based. Another trap I have fallen into before is using EDTF can create some issues so if possible use an alternative ASCII based editor such as notepad++, vi, etc.
I then ran the test to see what the output would be from a putty terminal and from the QP2TERM session. The QP2TERM session showed ‘Non Terminal session’ and the putty session showed ‘terminal session’. Now all that I needed to do was add the relevant code to launch a bash shell when it was a terminal session and do nothing when called from QP2TERM.
if tty -s
echo terminal session
echo Non Terminal sessionfi
Now when I start the putty session I get a bash shell. QP2TERM still uses the ksh shell.
if tty -s