My issue is actually very simple, but hard to address it directly. So please allow me to go around a bit. Back in the old days, when I used the Windows OS, before I issued a command from the command line, I need to first set the path variable so that the command can be executed automatically.
Now, on the SLED 11, I installed IBM WAS 8.5 developer edition. When I tried to check the status of the server, I went to the installation directory, /bin/ and then issue a command on the terminal:
serverStatus -all
RESULTS: bash: serverStatus.sh: command not found
This could be due to my working directory is not in the path. So, if I want to run a shell script from my current working directory, I have to invoke it: ./serverStatus.sh
My question, is there a way that I can set up a path or environment variable, so that whenever I type a command on the terminal such as the serverStatus.sh, it will automatically run the script?
Yes, but it’s not a good practice to do this for things you do not
expect to always be in the PATH which is why it is not a default.
windows does it, like so many things, erring in the side of convenience
rather than security. Still, since it’s easy to do, simply modify your
PATH, perhaps in your user’s ~/.bashrc script:
export PATH="${PATH}:."
Logout and login and you’ll see the changes. Still, you should just get
in the habit of running things like this as needed or else put
directories that have things that SHOULD be in your PATH into it. If
you make this change incorrectly you’ll make it easier for somebody to
trick you into doing things you do not like. Also, I’d strongly
recommend against ever doing this for the ‘root’ user.
Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
What ab says. One of the things I still remember from way back when I first encountered a Unix-like operating system whilst still in education, is a teacher telling us why the current working directory is not in PATH by default and why adding it is a bad idea.
Another alternative to adding /bin to PATH is you could put symlinks to things in /bin in somewhere that’s already in PATH. /usr/local/bin would be a good place.
$ cd /usr/local/bin
$ ln -s /path/to/was/home/bin/command .
repeat as needed. Some installers offer to do this for you if you’re running the installer as root.
If you don’t need the commands to be accessible to all users, (maybe you installed WAS in your own home directory where other users can’t see it) you could add the symlinks in ${HOME}/bin which gets added to PATH automatically if it exists.
This is the symptom of a poorly-written script in most cases. It is
treating the source of the symlink as its real location and so it looks
for things in /usr/local/bin instead of where the script really resides
in /IDM/AppServer/bin . Typically when I hit this I create a script
instead of a symlink which has three lines and that script resides in
~/bin or, in your case, /usr/local/bin :
#!/bin/bash
cd /IDM/AppServer/bin
…/serverStatus.sh
Good luck.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.18 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/