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

Aserre
  • 4,916
  • 5
  • 33
  • 56
Ahsan Naseem
  • 1,046
  • 1
  • 19
  • 38
  • 1
    >>> import os >>> os.environ["PATH"]+="/dodo/" >>> print os.environ["PATH"] This seems to work – Ahsan Naseem Jan 25 '19 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`. – Aserre Jan 25 '19 at 14:33
  • 1
    If you still want to do this : https://stackoverflow.com/questions/4081330/how-do-i-modify-the-system-path-variable-in-python-script – Aserre Jan 25 '19 at 14:33
  • 1
    Why don't you just invoke the executable using the full path? `/tmp/aws-iam-authenticator` – glenn jackman Jan 25 '19 at 15:29
  • 1
    If you script relies on `aws-iam-authenticator`, why are you installing it to `/tmp`, rather than somewhere already accessible? – chepner Feb 23 '20 at 14:53

0 Answers0