cc problems

VGZ

Registered
I've been trying to compile some source code from my computer science 150 class using cc. I'm not renaming it so it just creates an a.out file. There is no problem when I run cc; however, when I try to run the a.out file it says "a.out: Command not found." :confused:. The a.out file is in the directory I'm in when I try to run it. Any ideas on how to fix this.

Thanxs in advance,
 
When you type a command/program name without specifying its full location, _only_ your path is searched for that program. And by default, your path does _not_ include your current directory.

So to run something that's "right in front of you," you need to be a bit more explicit: in this case: ./a.out

The leading ./ makes it clear that you mean something in the current directory.

As a side note, you can change your path to include ".", which will then allow you to run things in your current dir implicitly. But this is generally not advised, as it can turn out to be a security risk. (It can make you less aware of what you're running, which could potentially lead to you running someone else's trojan with your permissions. A small risk, but still one worth avoiding.)

 
how would I change my path in OS X? I probably won't be running anything without knowing what it is.

Thanks for your help :),

[Edited by VGZ on 11-20-2000 at 06:26 PM]
 
Your path is kept in a shell variable named PATH, as a series of directory names separated by colons.

In Bash, which i am using, you would view your PATH by saying echo $PATH and add . (the current dir) to your PATH by saying PATH=$PATH":."
...but you are not using Bash, you are using tcsh. Right? So i'm not quite sure. Check the tcsh documentation to see how you edit shell variables.

Oh, one other thing: changing a shell variable is not permanent. Changes only affect the current session.. so once you close that Terminal window, or open a new one, your changes to $PATH will have been reset to what they were before. You will have to add whatever line you used to add . to your path into your shell init script, so it will be run every time you open a shell session. I'm not sure what your shell init script would be named. Probably .tcshrc or .tcsh_session. Again, see the documentation.

Hello. Welcome. This is what UNIX is like. -_-
 
Back
Top