2

I want to update path from python script i-e add /tmp in $PATH. Reason is I am using aws lambda and it looks for aws-iam-authenticator binary. Now this binary has to be in $PATH otherwise it throws error:

[Errno 2] No such file or directory: 'aws-iam-authenticator': 'aws-iam-authenticator'

Since only /tmp is writeable in aws-lambda I can not move this binary to any other /bin/* or PATH dir.

I tried doing this:

subprocess.call('PATH=$PATH:/tmp/',shell=True)

But it doesn't work.

Lambda path: PATH=/var/lang/bin:/usr/local/bin:/usr/bin/:/bin:/opt/bin

5
  • 1
    >>> import os >>> os.environ["PATH"]+="/dodo/" >>> print os.environ["PATH"] This seems to work Commented Jan 25, 2019 at 14:03
  • 2
    That's a pretty bad idea imo. That would that any program you put in your tmp folder will be in your PATH which may lead to problems when resolving executable real path. A better way to solve your issue would be to move the aws-iam-authenticator binary to a folder in your path (/opt/bin for instance). You may need to play around with chmod and chown. Commented Jan 25, 2019 at 14:33
  • 1
    If you still want to do this : stackoverflow.com/questions/4081330/… Commented Jan 25, 2019 at 14:33
  • 1
    Why don't you just invoke the executable using the full path? /tmp/aws-iam-authenticator Commented Jan 25, 2019 at 15:29
  • 1
    If you script relies on aws-iam-authenticator, why are you installing it to /tmp, rather than somewhere already accessible? Commented Feb 23, 2020 at 14:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.