0

(I'm not quite sure if this is the place to ask this, if need be please move to another Stack Exchange community - if possible)

I am learning C++ on my Raspberry Pi (With Raspian (Debian), btw), and I have created a simple Hello World program with the Geany IDE. I compile, build the program, and then run it. However, I get an error:

./geany_run_script.sh: 5: ./geany_run_script.sh: ./HelloWorld: Permission denied


------------------
(program exited with code: 126)
Press return to continue

The compile command is g++ -c "%f" and the build command being g++ -o "%e" "%f". If you find it helpful the file type is .cxx.

I would like to use Geany to run due to convenience. Unfortunately I can't run it with the Terminal as super user, even after using chmod +x.

Lachlan
  • 1,245
  • 5
  • 18
  • 34
  • Please show file permissions of HelloWorld – frlan Oct 22 '14 at 16:46
  • For me g++ always add +x flags to file. Isn't you working on some USB drive with fat or NTFS partition? Run `mount` command and check for `noexec` flag for device where your current dir is. – Arpegius Oct 22 '14 at 21:52
  • @Arpegius yes, I am working on a USB with FAT32. I'll try that as well – Lachlan Oct 23 '14 at 04:21
  • In this case please also post what mount is saying for the USB device – frlan Oct 23 '14 at 06:40
  • @frlan Will also do that but am not using my RPi ATM, will tell you when I have done that as well – Lachlan Oct 23 '14 at 09:30

2 Answers2

0

Your problem seems do not relates to Geany IDE. So you need to change permissions on executed file. Please try the following command: chmod 777 your_filename

zh_
  • 95
  • 8
0

To run a file on Linux the user needs to have the x either on user or group. This looks like ---x--x--x or in hex 0111 on POSIX file systems. So chmod +x should work on most systems using e.g. EXT[2|3|4] or XFS. So your start was correct. BTW: When compiling a C file via Geany, it's already set to be executable.

As you mention your USB stick is formatted with FAT32 which is not supporting the POSIX things here so chmod will not take any effect. However, the file permissions are e.g. to execute something is based on the umask used for mounting. On traditional Linux systems this can be configured in /etc/fstab. Using udev or something else, somewhere else it can be also configured (read: than it depends, what you are using to mount the stick)

In addition mount can set a device as noexec which pretty much is an good idea for devices as USB-sticks or unknown CD/DVD. However, if this flag is set during mounting, your files on that device can't be executed -- only read and write is permitted. Again this can be set on /etc/fstab or maybe somewhere else depending on what you might using in addition.

To check this, run the mount command without and parameters. It will give you a list where your USB device should be included.

frlan
  • 6,950
  • 3
  • 31
  • 72