LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 04-09-2004, 10:47 AM   #1
jleyba213
LQ Newbie
 
Registered: Apr 2004
Posts: 1

Rep: Reputation: 0
Problem executing from command line


I just installed SuSE 9.0 on my PC and wanted to try out a simple test C++ program. It was just your standard Hello World program, and it compiled fine. But I couldn't get it to run. I typed:
"a.out"

And I got back somethign to the effect of:
"bash a.out not recognized"

How do I "fix" this?

Sorry that I don't have the exact error message, but I don' thave the internet working yet for SuSe and forgot to write it down, so when I switched over to windows I had to remember it off the top of my head...

Anyway, help would be greatly appreciated.
 
Old 04-09-2004, 11:15 AM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
Hopefully you have the programs already installed. The file you are making needs to be compiled first. If that works ok, it will create another file called a.out which is the execute file.
For example, I make a file called test.cpp and compile it with the command:
g++ test.cpp
Then I use the command: ./a.out to run the results.
 
Old 04-09-2004, 11:17 AM   #3
larrykeenan
Member
 
Registered: Apr 2004
Location: Brisbane Australia
Distribution: UBUNTU 13.04
Posts: 59

Rep: Reputation: 19
Hi
Two things come to my mind.
1 Did you set the permission on the file to alow it to execute?
2 If your current directory is not in your path, you need to type ./a.out

The period in the above command simply means the current directory. In most distros ~/bin is in the default path so if you create a bin directory in your home directory and put a.out there, You could run it from anywhere.

Have Fun
Larry
 
Old 04-09-2004, 11:21 AM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 56
You beat me to it larrykeenan!

I was just going to remind jleyba213 to make sure the a.out file has execute permissions
 
Old 04-09-2004, 12:43 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,753

Rep: Reputation: 719Reputation: 719Reputation: 719Reputation: 719Reputation: 719Reputation: 719Reputation: 719
In addition:
Like ./ is a shortcut for the current working directory ~ is a shortcut for your home directory i.e. /home/<user_name>/

a.out is the default executable for gcc.
gcc -o helloworld hello.c
would create an executable called hello. To run the application
./helloworld

See man pages gcc for additional help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting 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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem executing mv command inside shell script pablogosse Linux - General 7 12-16-2009 12:21 PM
Problem executing this piped command: JAVA randomx Programming 1 07-16-2004 07:39 PM
executing from command line nodger Linux - Newbie 3 01-20-2004 10:30 AM
PostgreSQL: executing a .SQL file from command line? J_Szucs Linux - Software 0 09-24-2003 11:49 PM
Problem getting to command line... ChaosJunkee Mandriva 5 09-14-2003 05:26 PM


All times are GMT -5. The time now is 03:14 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration