Code Blocks Permissions

Hello, I’m relatively new to Linux and am starting some programming classes this fall. I decided to learn as much as I could before then, so downloaded Code::Blocks IDE to get started with some C++ tutorials I found on the web. The problem I’m having is that when I try to compile and run a simple Hello World type program, I get the following error in the console window that pops up:

sh: /home/seth/Documents/LearnCPP/Day2_1: Permission denied

The permissions on that file are -rw-r–r-- but I don’t think that is the problem. I’m thinking maybe I didn’t install codeblocks the proper way or something. In the Environment setting in codeblocks, it lists the following:

Shell to run commands in: /bin/sh -c
Terminal to launch console programs: xterm -T $TITLE -e

Can anyone point me in the right direction to help solve this problem? Thank you.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The error is exactly as you said it is. You are trying to execute that
file, which doesn’t make sense. What type of file is Day2_1?

file /home/seth/Documents/LearnCPP/Day2_1

If it’s a .cpp file you should try compiling it to make an executable
but otherwise, as you posted, that file is not executable so trying to
“run” it as you are will not work. If it’s just a plain text file with
instructions try using ‘cat’ or ‘less’ to access it:

cat /home/seth/Documents/LearnCPP/Day2_1
less /home/seth/Documents/LearnCPP/Day2_1

Good luck.

Sethusoid wrote:
| Hello, I’m relatively new to Linux and am starting some programming
| classes this fall. I decided to learn as much as I could before then,
| so downloaded Code::Blocks IDE to get started with some C++ tutorials I
| found on the web. The problem I’m having is that when I try to compile
| and run a simple Hello World type program, I get the following error in
| the console window that pops up:
|
| sh: /home/seth/Documents/LearnCPP/Day2_1: Permission denied
|
| The permissions on that file are -rw-r–r-- but I don’t think that is
| the problem. I’m thinking maybe I didn’t install codeblocks the proper
| way or something. In the Environment setting in codeblocks, it lists
| the following:
|
| Shell to run commands in: /bin/sh -c
| Terminal to launch console programs: xterm -T $TITLE -e
|
| Can anyone point me in the right direction to help solve this problem?
| Thank you.
|
|
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIaVl73s42bA80+9kRAsJvAJ4tODPB4vXwnkSuOLHc71Lo407MOgCfdVIw
hwc3Mc6Lm1LZx1BXLE/B6aM=
=NBgf
-----END PGP SIGNATURE-----

Well as I stated, I was trying to “compile and run” the file which was saved as a .cpp text file. I have gotten it to work now. Seems it wasn’t really a permissions problem. I added the following line in my code before the int main() declaration:

using namespace std;

I understand what this line is saying but not quite sure why I needed to add it since everyone of these C++ tutorials doesn’t seem to mention it lol. So it looks like I fixed my first bug even though I’m not sure of the reasoning behind the fix lol. Thanks for your reply.