Chmod command problem

This is a discussion on Chmod command problem within the C Programming forums, part of the General Programming Boards category; I am trying to create an executable, according to my lecturer to turn his sample solution into an executable to ...

  1. #1
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463

    Chmod command problem

    I am trying to create an executable, according to my lecturer to turn his sample solution into an executable to run on windows I need to type:

    chmod a+x hw3

    I did that, but it still doesn't make it executable

    Suggestions?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,556
    Huh?

    You compile the code on the machine you want to run it on, using the compiler which is native to that machine.

    You can't just take a random executable from one type of machine and expect it to run on another.

    Post your code and state your OS/Compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    chmod is a UNIX command (similar to the attrib command on DOS/Windows).
    To run a program on Windows you need to compile it on Windows. The binary format of UNIX programs and Windows programs are completely different.

  4. #4
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    The compiler is GCC.

    And yes you can, I've done it before by mistake, I just forgot how to do it because I never really knew it in the first place, just did it by accident.

    We have to do an assignment, so the lecturer has given the "sample solution" which is a binary, and to make it into an executable we have to type chmod a+x <filename>

    That doesn't work completely, I remember this happened to me once before, and I typed in some extra command and then it did become executable, but I just don't remember what I did.

  5. #5
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    This is what the lecturer says:

    2) How do we run the compiled version, and how can we test our program?

    First, copy hw1 to your own directory. You will then need to make it "executable" by typing:

    $ chmod a+x hw1

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    And what error are you getting after you run the chmod command? You haven't said.

  7. #7
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    No errors, it seems to execute fine, it just doesn't create an executable

  8. #8
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    hw1 is the executable. To run the executable, simply type hw1. Look up chmod on your *nix machine, it changes file permissions. Post any error you get after typing hw1.

  9. #9
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Command not found.

    Lol, forget it, I'm just going to run it from my Uni computer now. It works on that, but not on my laptop.

  10. #10
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    try ./hw1

  11. #11
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Nope, doesn't work, tried that ages ago

  12. #12
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >I'm just going to run it from my Uni computer now
    That's the only way to run it. If you want to run it on your laptop, you'll have to ask your lecturer for the source code.

  13. #13
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    That can't be.

    For my last assignment, it was in the same way, he released the binary, and I did run it on my laptop, same OS, Windows Vista, that chmod didn't work, I was messing around with some commands, and I turned it into an executable, I don't know how, but I did.

  14. #14
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    are you sure it wasn't a windows binary to begin with?

  15. #15
    Registered User
    Join Date
    Oct 2001
    Posts
    2,934
    >For my last assignment, it was in the same way, he released the binary
    What was that one called, hw0?

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with my copy programme
    By Tru_Messiah in forum C Programming
    Replies: 8
    Last Post: 12-15-2004, 09:04 AM

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