Not having to prepend compiled commands with ./?
How can one make it so that compiled commands can be executed without having to prepend them with './'? For instance given the g++ compiled command a.out, executing with just 'a.out' instead of './a.out'.
|
You would have to add the directory where you built the command to your PATH variable. For example, if you are compiling in /home/SirTristan/neatstuff, then you would need to add /home/SirTristan/neatstuff to PATH. The other option is to tell g++ to output the executable to a directory that is in your PATH (and you have write permissions) using the -o switch.
|
Put the directory where the command resides on your PATH. You can show your PATH with:
echo $PATH You can add a directory (for example /home/user/test) to your PATH with: PATH=$PATH:/home/user/test export PATH ------------------- Steve Stites |
When you prepend ./ to a command you are telling bash to look for the command in the current directory.
You could add . to your $PATH, but this is considered a poor move security-wize. There used to be quite a bit of discussion on the old linuxnewbie.org forums about the pros and cons of this practice. |
Suggest : rename a.out to something else and move or copy it
to /usr/local/bin (If you only have 1 a.out, the name a.out is OK) Then it is in your path. Rgds |
What's so arduous about having to type two extra characters anyway? ./ there, even a lazy **** like me can do it. :)
|
If these are useful programs you will use again, create a bin dir in your $HOME directory and add $HOME/bin to your path.
The system profile script may even check for a $HOME/bin directory and add it to the path if it is present. You can put handy scripts in there as well. |
Quote:
|
All times are GMT -5. The time now is 11:08 AM. |