LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-02-2009, 01:40 PM   #1
mominmyheart
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Rep: Reputation: 0
Question Permission denied when compiling C program


Hello:
I am writing a C program and trying to compile it under fedora9 when I type
gcc filename.c -o filename it suceeds but when I type ./filename.c it gives me Permission denied.
I am working in my code on threads basically using clone. Is there any relationship with this line
#define CLONE_VM 0x00000100
 
Old 12-02-2009, 01:42 PM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Did you type ./filename.c or ./filename? You would enter the latter to execute your program.
 
Old 12-02-2009, 01:51 PM   #3
mominmyheart
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Original Poster
Rep: Reputation: 0
I put ./filename.c first and it gave me permission denied but when I put ./filename it doesn't show anything. Does this mean there is certain problem in my code?
 
Old 12-02-2009, 01:56 PM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
Probably. Your first command is trying to run the source code which is wrong. Sounds like it is debugging time.
 
Old 12-02-2009, 01:59 PM   #5
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
I don't have a clue what your program is supposed to do, but is it supposed to output anything (text?) to the screen when it executes? If not, then when you execute it, it will either run and exit silently, or run and exit with an error.

As for when you type ./filename.c you are in effect trying to execute a text file. "Permission denied" happens most likely because the file is not set with "execute" bit. If you do the command:

shell$ chmod a+x filename.c

then it will be executable, but there's no point; it won't run, because it's a .c source code file (a text file, not a shell executable or binary).

Like Jim mentioned above, your compiled binary should be called "filename"; that's what you want to execute after the source has been compiled.

Sasha
 
Old 12-02-2009, 01:59 PM   #6
mominmyheart
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Original Poster
Rep: Reputation: 0
Sorry but I didn't I understand what you mean?
 
Old 12-02-2009, 02:10 PM   #7
mominmyheart
LQ Newbie
 
Registered: Nov 2009
Posts: 10

Original Poster
Rep: Reputation: 0
I think I got your point but the executable file has appeared on the desktop but no results. My program suppose to output certain lines.
 
Old 12-02-2009, 04:49 PM   #8
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Well then, it sounds like your program does not work

I am going to request a move of this thread, to the programming forum, where it may get better exposure to other programmers who might be able to offer advice.

Sasha
 
Old 12-02-2009, 05:05 PM   #9
raju.mopidevi
Senior Member
 
Registered: Jan 2009
Location: vijayawada, India
Distribution: openSUSE 11.2, Ubuntu 9.0.4
Posts: 1,155
Blog Entries: 12

Rep: Reputation: 92
I think you are using wrong command.

you can execute *.c file , so this command is wrong
Code:
$ ./filename.c
follow this commands
Code:
$  gcc -o filename filename.c
$  chmod 744 filename
$  ./filename
to know building C programs see this
 
Old 12-02-2009, 05:08 PM   #10
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Quote:
Originally Posted by mominmyheart View Post
I think I got your point but the executable file has appeared on the desktop but no results. My program suppose to output certain lines.
first, you have to compile. If that is successful, then you have to run the executable file.
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to run program, Permission denied smartgupta Solaris / OpenSolaris 3 08-11-2009 01:49 AM
bash: ./program: permission denied Cinematography Linux - General 3 10-01-2007 08:18 PM
Permission Denied when running a program? tolvar Linux - Newbie 1 09-07-2005 08:18 AM
compiling: permission denied batgranny` Linux - Software 5 08-08-2004 12:49 PM
bad interpreter: Permission denied when compile any program docesam Linux - Software 4 06-05-2003 11:05 PM


All times are GMT -5. The time now is 10:13 PM.

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