 |
 |
Question involving CC
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Louisiana
Status:
Offline
|
|
Just fooling around with CC before I head to class, I compiled a program I recently wrote for a class. Got the usual warnings that I got when I compiled it on the Unix machines at the University. Problem is, I can't run the a.out file. On a unix machine, you type gcc(cc for X) filename. At the next prompt, you type a.out(the file that was just created) and it shows the output. Well, when I type a.out, it says that the command a.out doesn't exist???? What's going on here?
|
|
B&W G3/300 OS X 10.3 Server
AL G4/1.5 OS X 10.3
Next computer G5/3.X Ghz OS X 10.x.x
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Oct 2000
Location: boston ma
Status:
Offline
|
|
Originally posted by jguidroz:
On a unix machine, you type gcc (cc for X) filename. At the next prompt,
you type a.out(the file that was just created) and it shows the output.
On a unix machine that doesn't have your current directory in the path, you
type ./a.out
|
|
|
| |
|
|
|
 |
|
 |
|
Mac Enthusiast
Join Date: Sep 2000
Location: Louisiana
Status:
Offline
|
|
Thanks!
Now I wonder is there is a way to fix this so I don't have to type ./
|
|
B&W G3/300 OS X 10.3 Server
AL G4/1.5 OS X 10.3
Next computer G5/3.X Ghz OS X 10.x.x
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Oct 2000
Location: Arlington, VA
Status:
Offline
|
|
Originally posted by jguidroz:
Thanks!
Now I wonder is there is a way to fix this so I don't have to type ./
There certainly is. But please DON'T DO IT!!  All you need to do is add "." to your PATH. This means that whenever you type a command, the shell will search the current directory. HOWEVER, keep in mind that this is considered to be a significant security risk, particularly if you will be logged in as root. The "solution" leaves you vulnerable to running trojan horses. For example, you could untar an archive and change into the directory. Now, if someone had put an executable called 'ls' in the directory, it could do anything your current user could do, which would range from inconvenient to downright destructive. Consider my workflow when I download a file:
tar -xvzf filename.tgz
cd filename
ls
If I had ./ in my PATH and the shell looked there first, such a trojan would get me every time.
YMMV!
petard
[This message has been edited by petard (edited 10-25-2000).]
|
|
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Sep 2000
Status:
Offline
|
|
You can add the current directory to your path by adding the following line to your .tcshrc file (in your home dir):
setenv PATH {$PATH}:.
This causes the shell to search the paths already set up before it finally looks in the current directory, thereby avoiding the same-name-as-a-command problem.
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
Forum Rules
|
 |
 |
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|