 |
 |
Beginning Student Developer - how to run "a.out"
|
 |
|
 |
|
Junior Member
Join Date: Apr 2000
Location: Minneapolis, MN
Status:
Offline
|
|
Hi, I'm a newbie and I need some help. I just used the c++ compiler that came with my developer tools CD to compile a really really simple c++ program (only slightly more complex than a "Hello World."
Anyhow, I've compiled it, and as you know the compiler leaves it as an "a.out" file. How can I run this from the command line? That's all it necessitates. It outputs some text, I input some text... so on.
How can I get this to run in the Terminal? Is it possible?
Thanks for any and all help. I hope this isn't a repeat question. If it is, just refer me to the answer.
JL!
|
|
If senility were a race, I would win.
|
| |
|
|
|
 |
|
 |
|
Forum Regular
Join Date: Sep 2000
Status:
Offline
|
|
I apologize if this is too simple, but...
Have you tried typing "./a.out" and pressing Return? By default, the current directory is not in your path for executing programs, so if you're just typing "a.out" it will probably complain that it can't find the file. Typing the dot-slash in front of it forces the shell to look in the current directory.
Also, you can use the -o option to specify a name for the output file if you don't want to call it "a.out".
|
|
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Apr 2000
Location: Minneapolis, MN
Status:
Offline
|
|
The "./a.out" worked! I already knew about the -o command, but I appreciate the help.
[This message has been edited by JL! (edited 09-30-2000).]
|
|
If senility were a race, I would win.
|
| |
|
|
|
 |
|
 |
|
Mac Elite
Join Date: Sep 2000
Location: in front of the keyboard
Status:
Offline
|
|
Oh my lord!!! What is this world coming to! I don't mean to flame, and don't take this personally, but what school do you go to, where you learn C++ but don't know how to run a.out?
When I got my BS, we were all Solaris. I shutter to think that Windoze is that entrenched that Universities are actually teaching C++ on PeeCees!
No wonder Unix sysadmins can pull in $100K here in Phoenix.
[This message has been edited by Kristoff (edited 09-30-2000).]
|
|
signatures are a waste of bandwidth
especially ones with political tripe in them.
|
| |
|
|
|
 |
|
 |
|
Senior User
Join Date: Mar 2000
Location: Palatine, IL
Status:
Offline
|
|
Hey now... I learned some C++ in high school, and we used SOIUX on Macs. I am a CS major, but a freshman and haven't had any CS courses yet. I can totally empathize. Thanks for asking this question - it will help me out greatly! (I wouldn't have known what to ask, even.)
------------------
We're supposed to sing about piraty things!
|
<a href="http://www.macronyms.com" target="_blank">  </a>
kelsevinal: i am impervious to your "nerd" attacks
|
| |
|
|
|
 |
|
 |
|
Junior Member
Join Date: Apr 2000
Location: Minneapolis, MN
Status:
Offline
|
|
Actually, we didn't begin using M$ Visual C++, we started just by using CC on a Solaris, and then g++ on Solaris and M$ Visual C++ on a PC came in later. The thing is... When I telnet into the Solaris machines running Sun OS 5.8, all I have to do is type "a.out" and they execute the program. None of this silly "./a.out" stuff. That makes no sense. I wish I could set it to not do that.
Think of it this way. Maybe M$ is that well entrenched in my school, but Marshall, by not flaming me, released me from that prison and let a new Mac programmer program totally on his own computer (without tying up the phone line). That rocks. Thanks Marshall.
|
|
If senility were a race, I would win.
|
| |
|
|
|
 |
|
 |
|
Pukku
|
|
Hmmmm... it is, theoretically, possible to set up the path so that you don't have to type ./ (although, personnaly, I prefer having to type it). Since you will only need to do this from the terminal, I would suggest starting by looking at /etc. There are a few files: I think called csh.login, cshrc, or something along those lines. You can also look in /usr/share/init/tcsh (unless you've changed your shell). Basically, you need to change the PATH variable. I'm not sure if you can just add "." to it, or if you have to add a specific directory, as I've never tried. As long as you are using tcsh (the default shell), you would need to add a line like "setenv PATH=.;$PATH" to a file somewhere -- or change the initial setup of the PATH variable to include the ".". Try typing "man tcsh" and reading the shell's manpage to figure out what files it uses.
I know that if you create the init/tcsh dir in ~/Library/, you can automatically have it set up a number of things. I created the aliases.mine file and have ls='ls -aF' set by default.
Have fun!
Ricky
|
|
|
| |
|
|
|
 |
|
 |
|
Professional Poster
Join Date: Jan 2000
Status:
Offline
|
|
How about this
>find / -name "a.out" -exec {}\;

|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Sydney, Australia
Status:
Offline
|
|
Originally posted by JL!:
all I have to do is type "a.out" and they execute the program.
That means . is in your path. . represents the current directory.
None of this silly "./a.out" stuff. That makes no sense.
That is I think I disagree...
Think of this scenario. You are a UNIX admin. The user "evil_user" rings you up to say that he has these files in his directory he cant get rid of. Suspecting the files probably have something in their names that is hard to type you su to root and:
cd ~evil_user
ls
Now when you type ls what does the shell do? It searches your path. You have . in your path so the shell looks in the current directory (evil_user's home directory). In there it finds the ls binary placed there earlier by evil_user so it runs it. The binary installs a backdoor in the system before deleting itself and calling the real ls.
The only output was from the real ls so you don't notice anything untoward.
You delete the funny files in evil_user's directory (muttering about lame users who don't know what a quote is ;-) and wander off oblivious to the fact that your password file is being posted to USENET and your companies trade secrets are being sold to your competitors for quite a tidy sum. evil_user cleans up the back door and leaves for his new job...you might be looking for a new one as well soon...
I wish I could set it to not do that.
Put . in your path. In your .tcshrc (assuming ou are running tcsh) place the line:
set path=($path .)
By putting . last it means that when you type ls it should pick up /bin/ls before ~evil_user/ls. Of course if you ever make typos you are still at risk...
Andrew
[This message has been edited by Andrew [Not Registered] (edited 10-01-2000).]
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
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
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|