views:

60

answers:

3

I have a program written in C, which is named computeWeight.c and to compile it i use the following code

chaitu@ubuntu:~$ gcc -Wall -o computeWeight computeWeight.c
//to execute it:
chaitu@ubuntu:~$ ./computeWeight

Do i have any mechansim where i can directly use as mentioned below,

chaitu@ubuntu:~$ computeWeight

Should i be changing any permissions on the executable to get this?

A: 

export PATH=$PATH:.

osgx
...Do we know what shell is being used from the question?
Platinum Azure
In the absence of the shell being specified in the question or tags, given that the question is tagged linux, assuming bash is a safe assumption.
camh
@people, there was an "@ubuntu" in question. So, by default it will give to user tha bash
osgx
+3  A: 

You need to add "." to your path. Some people regard this as dangerous, though. See for instance http://www.arsc.edu/support/policy/dotinpath.html .

lhf
+1  A: 

The $PATH variable define the places where linux would look for executables (try typing echo $PATH in a terminal). You need to put that file in one of those places. One way is to add a bin folder in your home directory, put the executable file there, and add this line (which adds the bin directory in your home folder to the search path) to your .cshrc file so that it'd be executed for every shell:

set PATH = ($PATH $HOME/bin) 

With that said I don't think typing ./ is that bad.

Firas Assaad
This is safer than adding "." to one's PATH as other answers suggest, and also more convenient since it works even when you're not in the directory where the program is located.
Wyzard