Description
When executing commands via UssCmd.issueCommand(), environment variables defined in /etc/profile or ~/.profile (such as PATH or STEPLIB) are not loaded. This causes mainframe commands dependent on these profiles to fail with file-not-found or execution environment errors.
Cause
The ManagedChannel class opens a JSch ChannelExec ("exec") connection. By default, SSH daemons treat exec channels as non-interactive, bypassing the execution of standard shell login profiles.
Proposed Solution – Update Documentation
Add guidance to the Javadoc and README.md explaining that SSH exec channels do not automatically load the user's login environment. Document how to mitigate this behavior by prepending the appropriate shell profile commands to the command string before execution.
Example:
// The SSH "exec" channel does not load the user's shell profile.
// Source the profile before executing the requested command.
command = "[ -f /etc/profile ] && . /etc/profile 2>/dev/null; " +
"[ -f ~/.profile ] && . ~/.profile 2>/dev/null; " +
command;
This approach ensures that environment variables, aliases, and other shell configuration settings defined in the user's profile are available during command execution.
Description
When executing commands via
UssCmd.issueCommand(), environment variables defined in/etc/profileor~/.profile(such asPATHorSTEPLIB) are not loaded. This causes mainframe commands dependent on these profiles to fail with file-not-found or execution environment errors.Cause
The
ManagedChannelclass opens a JSchChannelExec("exec") connection. By default, SSH daemons treatexecchannels as non-interactive, bypassing the execution of standard shell login profiles.Proposed Solution – Update Documentation
Add guidance to the Javadoc and
README.mdexplaining that SSHexecchannels do not automatically load the user's login environment. Document how to mitigate this behavior by prepending the appropriate shell profile commands to the command string before execution.Example:
This approach ensures that environment variables, aliases, and other shell configuration settings defined in the user's profile are available during command execution.