I have a script that I am running on multiple Linux OSs. The shebang line of my script is:
#!/usr/bin/python
When I came across CentOS 8, this doesn't work as I get the following: "-bash: ./sysinfo-snapshot.py: /usr/bin/python: bad interpreter: No such file or directory"
And as a workaround I can change the shebang line to
#!/usr/bin/python3
and this would 100% solve the issue.
However, what I'm looking for is to have my script try the first shebang line, and if it didn't work, to try the second line, as in, 2 first lines in the code would be:
#!/usr/bin/python
#!/usr/bin/python3
Is this possible? Is there a way to support both python and python3 for the script? As in first try the first shebang line, if it didn't work try th second line.
Things I tried to far:
I tried changing the shebang line to: #!/usr/bin/env python
But it didn't work.
Thanks