How can i run a bash script from new environment?
I try to do it like this, but its not working
#!/bin/bash
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/opt/dell/srvadmin/sbin:/root/bin"
racadm getsvctag > /root/Desktop/serialTest.txt
2
Answers
You can run your bash script in a new environment if you replace your shebang line with:
Don’t you mean instead of the
PATCH
variable thePATH
variable?Note: If you export your variable it will be system wide available.
The following is not a proper solution, but anyway, this is a way to run different version of interpreters (bash, python, php…), and make them portable. It will works on other machines of the same architecture only.
Copy the interpreter binary, in your working folder:
Own it and make it executable:
Test script, calling the interpreter from the current dir:
A better solutions with good documentation can be the tools linuxdeploy and/or appimage, this is using this method under the hood.
https://github.com/linuxdeploy/linuxdeploy
https://appimage.org/