List Working Directory in Path

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?

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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/

iQIcBAEBAgAGBQJQE4OUAAoJEF+XTK08PnB5ptEQALqh6uRfVUpm/Suap6Al2Gn+
Fvk5r77xKl2fdtA7cRCx/HO8R135ufymbNyk579aUgrSk6flTa3vnT+zrV/xHjoO
irJVN+8YEFVEq3WWi6EFYkN9TlhPtkffT7MyqfYtu5DwzspmcE8AhVzxL2oUkGUJ
Kaq/S4ZOJQwgZywwU5qVFQnZa4s+E/CLFHOGLe36V66HSub1GJqzpPR2oQiJn99z
q8LbhhfjT/3UEHGvCNx1cXAwt1zBeq89nQYOkb4iyqRPhcU2V/PmdGnrOAPlZBs2
W/CMtbhPDKqoWA3DNo/IIKeGcluO05v+Hw6qzchzdwRP5qfsoJmoEC+zpXDHvFb5
on7xUj3unCtbNAw4ITxg/bbS776AKwTI2jqpBE6R+hVhhuH97rqGxv/8ENdVXveU
A84LSMOGivw9VFTDAKNB12kZK5nNilLhcHG+DRbrFjn2q1TbdAE1R9dJ0eU/6+84
fBC3lgf2ynoKXdEC+y+vFGfMr98LPO3GbJk+KS7LOmGuY5iLDFz//99/rtFgsSVa
Nx/lcZmkxPc+yGWmZ6HSPtWD3u5u66QH+aXdUXxLAPANRWoiKhNeqIx9kFBWyrDI
Ee+l6ZlbjxONIGYyYrjw3yulojw6NUxmAceh75DE0LHKi8rthebowgDOrZTTfsMt
gFn90sRp8p9FXDaxHv9p
=dFvl
-----END PGP SIGNATURE-----

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.

Found some issue:

$ cd /usr/local/bin
$ ln -s /IBM/AppServer/bin/serverStatus.sh

$ serverStatus.sh -all

/usr/local/bin/serverStatus.sh: line 11: /usr/local/bin/setupCmdLine.sh: No such file or directory

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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/

iQIcBAEBAgAGBQJQFEEHAAoJEF+XTK08PnB5+3cP/2hPSTyOiRYaXGK3YwakfboR
nQweael4zdc2Kpz5bGpXqHl/3P11zp6wWnETjq5e4bqgOL2stl4AyKtsjSrPm7oC
bHZXoBSAidubh0R6PZzGEqZu5a1wujzG8JVkn+KKTkOo9nr05XadExhThbO+/+aq
Gbt3Z2UJ9GOfKH7T/FHQWUceU7FKb/OIHgKn8x1+9g5zTx5p3qz21G4Bxlw0kHdf
+LVxjZIDat3nFsGv7hif4j5YoJjPQocJ2cQxxQ9WBUm6s+VFEqM+TqEaBxjO7cJB
RRC+D4Bhs7REGUhB2REyrTiCAJj9TaDXMMwI4Vx3wlot+gBen+DN/UYEw5LOX956
iMOs4+7BP20ahSh+Ds8FI4G3yi+qmK3tT87qwu7Zy1HO4HR+mUurbvEKYaIUd9AR
Ic7mGkjpa4oXEGAUO3pv+faouS71muw46i3LzS2iCkaKeFqpOJW9PSNUhDJd2fdW
shJDiLkWSTiQw0B6gIXC422SXAb6S/VUXfNKD0625/muo2HfY4RYwRVy+AKneaYZ
c4InURxCk35ic4vayOoOtZ7uB7a2N7TqNxrS403wJ8butfByINGfi5s0mb2cQVdn
QsROAWNNLiWnV++QpaD2E03kKnFR5bJZ26cVmXcgsKt+ecRoXIca6EvHIdGjdTzn
J7JsT58dcopoRQRtsinx
=ir1w
-----END PGP SIGNATURE-----