Skip to main content
May 13, 2020 7:35 AM UTC

Python 3 usage without using .bashrc or .profile

Hi,
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 winmvs2c.hursley.ibm.com ‘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?

Cheers,
Michael Baylis
IBM Senior Software Engineer - CICS TS

    3 replies

    May 13, 2020 12:09 PM UTC

    Hi,
    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 winmvs2c.hursley.ibm.com ‘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?

    Cheers,
    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
    a

    regards,
    Rick Harris
    Rocket Software

    May 19, 2020 11:53 AM UTC

    Hi,
    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 winmvs2c.hursley.ibm.com ‘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?

    Cheers,
    Michael Baylis
    IBM Senior Software Engineer - CICS TS

    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.

    Vladimir Ein
    Rocketeer
    May 25, 2020 8:00 AM UTC

    Hi,
    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 winmvs2c.hursley.ibm.com ‘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?

    Cheers,
    Michael Baylis
    IBM Senior Software Engineer - CICS TS

    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'

    Regards,
    Vladimir