Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Question involving CC

Question involving CC
Thread Tools
Mac Enthusiast
Join Date: Sep 2000
Location: Louisiana
Status: Offline
Reply With Quote
Oct 25, 2000, 07:59 AM
 
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
Reply With Quote
Oct 25, 2000, 08:23 AM
 
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
Reply With Quote
Oct 25, 2000, 08:31 AM
 
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
Reply With Quote
Oct 25, 2000, 03:15 PM
 
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
Reply With Quote
Oct 26, 2000, 05:20 AM
 
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.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:50 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2