Permission Denied error

This is a discussion on Permission Denied error within the C Programming forums, part of the General Programming Boards category; I am guessing this is probably more of a Unix/Solaris problem but I figured I'd see if anyone has had ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    11

    Permission Denied error

    I am guessing this is probably more of a Unix/Solaris problem but I figured I'd see if anyone has had this problem. I am writing a Hash Dictionary ADT in C using the CC compiler. My code compiles fine but when I try to run it I get this error:

    HashDictionaryTest: Permission Denied

    Does anyone know what the problem is here, or is this a unix problem? Thanks for the help

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    16
    you should run it in superuser mode.Either log in as root or use the "su" and enter the root password

  3. #3
    Registered User
    Join Date
    Mar 2002
    Posts
    11
    I can't run in root mode because it is on a University machine and I don't have access to the root user. Thanks for the suggestion. Any other ideas?

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,138
    Either log in as root or use the "su" and enter the root password
    You shouldn't have to do this ever and definetly not to run a small university application. Obviously, your program is trying to do something your user has no rights to do. Write to files inaccessable to him, corrupting memory that does not belong to your program etc. Try to find out what fails. Try using a debugger.
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Registered User foniks munkee's Avatar
    Join Date
    Nov 2001
    Posts
    343
    Actually you'll probably find that the file has been created with the wrong permisions. The a.out output files are almost always created without executable permisions set as per your shell environments default permisions for file creation.

    Try:

    chmod 755 <filename>

    This will set the permisions to:
    -rwx r-x r-x

    You can check this with ls -l command.

    User: read write execute
    Group: read execute
    World: read execute

  6. #6
    Registered User
    Join Date
    Mar 2002
    Posts
    11
    Thanks for the help. It looks like the permissions were only set to read and write.

  7. #7
    Registered User
    Join Date
    Mar 2002
    Posts
    11
    Alright, changed the permissions so that I don't get the error about permission denied. I get a new error though, that follows:

    Cannot execute binary file.
    myspell: Exec format error

    Any ideas?

  8. #8
    Registered User foniks munkee's Avatar
    Join Date
    Nov 2001
    Posts
    343
    What are you trying to execute? How are you trying to execute it?

    I don't know how big your program is, but assuming it is a single c source file and you are not using make - then you may be doing something like this.

    > cc myspell.c
    > chmod 755 a.out
    > ./a.out

    Anyway, the error that you have recieved is telling you that the file that you have compiled is not a valid executable file under your current operating environment (OS and or hardware combo). It occurs when a request is made to execute a file that, although it has the appropriate permissions, does not start with a valid format.

    Did you compile the program and try to run it on a another machine?

    Or perhaps your uni is using NFS to mount the server partitions. NFS is a little slow in keeping files updated - the error is common when compiling on machine and executing on another, so once you have compiled your executable try using the sync command to ensure the files are updated.

    > sync

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21