Running files in Unix (Solaris and UX)

Arkitech

Diamond Member
Apr 13, 2000
8,356
4
76
When I work in Solaris and I need to run a file or script I typically run the command like this: . ./.programname I never understood the logic behind that, why is it necessary to run programs that way, would'nt it be simpler to use the DOS method by just typing out the filename along with the extension?

Just recently I've started working in a UX (11) environment and I tried to load up a script the same way in Solaris and I get can't find "programname" error. What am I doing wrong?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
It depends on the directory you are in. In your example ../.programname you are trying to run the program .programname in the directory above (../) your current working directory. If the directory above your directory is in your PATH environment variable ($PATH, echo $PATH to see your current path settings) then typing .programname should be sufficient.

Even in DOS the program has to be in your $PATH (%PATH?) for you to be able to run it without a path (the ../ stuff).

Often times people have to run programs in their current directory preceeded with a ./. . (dot) represents the current working directory, and is often exluded from the $PATH variable for debatable reasons (some people say it helps security). So, in order to run programname in your current directory without . or the full path to the directory (ie. if the program is in /usr/sbin, but /usr/sbin is not in your PATH) you will have to type ./programname. The shell then looks in the current working directory for the program.
 

Arkitech

Diamond Member
Apr 13, 2000
8,356
4
76
thanks for the help, that explanation makes sense

I think I managed to run the script I needed in UX but the alias commands that should have been loaded from that script are'nt working. Is there a way to verify that the script I loaded is running?
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
ps auxww | grep programname
or
ps ef | grep programname

depending on the ps command (you probably want the second one).