Products Resources Support About Us

Python 3 usage without using .bashrc or .profile

we have python 3 installed and working correctly when the $PATH and $LIBPATH are set. However, as I want to use python for running Ansible against the LPAR .bashrc and .profile can’t be used.

Ansible uses SSH remote commands to work, the equiv of:-

ssh ‘python --version’

How can I update USS so that python 3 is available for all users without relying on .bashrc or .profile and will work with non-interactive SSH sessions?

Michael Baylis
IBM Senior Software Engineer - CICS TS

You can set PATH as part of the ssh command.
for example,

ssh pdharr@rs25 PATH=/u/pdharr/miniconda/bin:/bin XYZ=a python -c “’”‘import os; print(os.getenv(“XYZ”))’"’"

will print

Rick Harris
Rocket Software

Hi Rick, that has worked thank you. Makes the anisble host inventory a bit messy:-

ansible_python_interpreter: ‘PATH=/python/v361/python-2017-04-12-py36/python36/bin:/usr/bin:/bin:/usr/sbin LIBPATH=/python/v361/python-2017-04-12-py36/python36/lib:/lib:/usr/lib python’

Would be nice if somehow in USS we can set this, but I can’t find it.

Hello Michael,

I’m not that good at Ansible so a couple of questions first:

  1. What’s your default shell - is it /bin/sh or bash?

  2. Is there a reason why you can’t use .bashrc (provided your default shell is bash) ? My understanding is that it gets executed on non-interactive logons as well.

  3. If you already have PATH/LIBPATH in .profile or some other script, can’t you just run that script before invoking python? Something like this:

ssh user@host '. ~/.profile; python --version'