In order to know which directories are mapped by the PATH, run:
echo $PATHA possible output is this:
/home/rafael/bin:/home/rafael/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8 oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/binThe mapped directories are split by two points. Some directories are mapped by default. As you can see ~/bin (/home/rafael/bin) is one of these. This means that if we add some scripts in ~/bin, we will be able to run those scripts from anywhere by just prompting the file script name.
Example: Running Wildfly10 server through the PATH
Assuming your Wildfly server is located at /usr/share/wildfly-10.1.0.Final, let's add to PATH two commands, one to start the server and other to start the server client interface whose full path is /usr/share/wildfly-10.1.0.Final/bin/jboss-cli.sh.
We are just going to create one file called wildfly10 (touch wildfly10) to start the server and other called wildfly_cli (touch wildfly_cli) to run the client, each one containing the respective scripts (echo "..."). After that we give permission (chmod 755...) to make these files executable and that's all.
Starting from your home directory, type:
cd bin touch wildfly10 echo "sudo /usr/share/wildfly-10.1.0.Final/bin/standalone.sh" > wildfly10 chmod 755 wildfly10 touch wildfly10_cli echo "sudo /usr/share/wildfly-10.1.0.Final/bin/jboss-cli.sh" > wildfly10_cli chmod 755 wildfly10_cliReady! Wildfly command is on your PATH. Let's try it:
First we start the server by prompting wildfly10 |
And now running the client server:
Prompting wildfly_cli from anywhere we start the client |
And accessing server http port:
localhost:9990 |
You can add any commands you want to the PATH!
No comments:
Post a Comment