LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   vi editor (https://www.linuxquestions.org/questions/linux-newbie-8/vi-editor-916221/)

afiqrahim 11-29-2011 11:24 AM

vi editor
 
$ store
Which file do you want to store: demo
Do you want to delete file demo in its current location? [y/n]: y
You can always retrieve the file with 'getback' later.
Good Bye
$

How do I write a program that starts with entering the program's name instead of having to enter ./(DotSlash) at the beginning.
The example of the output of the program is as stated above. A little help please :-)

kbscores 11-29-2011 11:29 AM

Add it to a bin directory or add script's location to path.

afiqrahim 11-29-2011 11:32 AM

Quote:

Originally Posted by kbscores (Post 4537475)
Add it to a bin directory or add script's location to path.

example?

b0uncer 11-29-2011 11:33 AM

Quote:

Originally Posted by afiqrahim (Post 4537467)
How do I write a program that starts with entering the program's name instead of having to enter ./(DotSlash) at the beginning.
The example of the output of the program is as stated above. A little help please :-)

The output has nothing to do with how you start the program. In a typical Unix(-like) environment you launch an executable (in a shell) by giving (full or relative to current working directory) path to it, along with the executable filename. Certain directories are searched automatically, for example /bin, /usr/bin, and so on. This means that even if you do not give full or relative path to the executable, i.e., you simply type the executable filename, certain directories (usually listed in an environment variable $PATH) are looked into, and if an executable of the name you gave is found in one of them, it is executed from there. If it exists in multiple directories that are searched, typically it is executed from the first directory where it is found.

To get your program to run "without giving path", you either put it into a directory that is automatically searched (see directories listed in $PATH), or add the directory, where the executable is, to the list yourself. Note: while it may be possible to have the system search for the current working directory first, meaning that you could execute any file within the current directory without typing the dot-slash, it might not be wise; this would make it a lot easier to accidentally run a program, which you usually do not want to do.

Nylex 11-29-2011 11:35 AM

If you're using Bash and your program is in /home/user/bin, add the following line to your .bashrc:

export PATH=$PATH:/home/user/bin

This appends the directory "/home/user/bin" to the list in the variable $PATH.

Also, your question has nothing to do with vi. In future, please try to use titles that are descriptive of your question/problem.


All times are GMT -5. The time now is 09:23 PM.