Like Tree2Likes
  • 1 Post By Salem
  • 1 Post By ZAMBROTTA

Plz help me, got stock ..

This is a discussion on Plz help me, got stock .. within the C Programming forums, part of the General Programming Boards category; Hi guys, I have 2 c program file, one of them is the main, and the other is data_file.txt . ...

  1. #1
    Registered User
    Join Date
    Feb 2013
    Posts
    6

    Plz help me, got stock ..

    Hi guys,

    I have 2 c program file, one of them is the main, and the other is
    data_file.txt . I'm using Linux computer, and cant run the program.
    first, I put both files in my home, then I wrote this:
    ./main data_file.txt

    but everytime get this commment:
    permission denied.


    plz hellllllllllllllllllllllp...

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    You need to compile your program, using say

    gcc main.c

    The result of that is an executable program called a.out (if all is well), which you run with
    ./a.out data_file.txt
    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
    Registered User
    Join Date
    Feb 2013
    Posts
    6
    Quote Originally Posted by Salem View Post
    You need to compile your program, using say

    gcc main.c

    The result of that is an executable program called a.out (if all is well), which you run with
    ./a.out data_file.txt
    Many thanks for your quick reply.
    but the main file does not has any extension, mean its only "mean" not "mean.c"
    when I change it's name to mean.c, I got some unreadable things inside this file.
    can u help me again plz, thanks alot

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    985
    Quote Originally Posted by ZAMBROTTA View Post
    Many thanks for your quick reply.
    but the main file does not has any extension, mean its only "mean" not "mean.c"
    when I change it's name to mean.c, I got some unreadable things inside this file.
    can u help me again plz, thanks alot
    File extensions are not used on Linux for determining whether something is executable, however, gcc itself uses the extension to tell it something about the input file. For example, a text file with a .c at the end means it is a C source code file. Renaming an executable file as .c, for example, is wrong.

    Try the following command

    gcc -o main main.c

    That means to compile a text file called main.c and output an executable file called main. Then you should be able to do this if it worked:

    ./main

  5. #5
    Registered User
    Join Date
    Nov 2012
    Posts
    32
    @ZAMBROTTA
    Try
    chmod +x main

  6. #6
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    Code:
    $ ls -l a.out
    -rwxrwxr-x 1 user usergroup 8844 2013-02-10 14:06 a.out
    $ file a.out
    a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
    $ file bar.c
    bar.c: ASCII C program text
    First you do "ls -l" on your main file. Is it marked as executable? (that's the first 'x' in the rwxrwxrwx permissions) If it isn't, then you can't execute it.
    Then you use the "file" command to see what kind of file it is. If it lacks any mention of "executable" (like bar.c has, which is just C program text), then you can't execute it.
    Now do "ls -l" on your data file. Is it owned by you? does it have 'r' permissions on it?
    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.

  7. #7
    Registered User
    Join Date
    Feb 2013
    Posts
    6
    Quote Originally Posted by Salem View Post
    Code:
    $ ls -l a.out
    -rwxrwxr-x 1 user usergroup 8844 2013-02-10 14:06 a.out
    $ file a.out
    a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
    $ file bar.c
    bar.c: ASCII C program text
    First you do "ls -l" on your main file. Is it marked as executable? (that's the first 'x' in the rwxrwxrwx permissions) If it isn't, then you can't execute it.
    Then you use the "file" command to see what kind of file it is. If it lacks any mention of "executable" (like bar.c has, which is just C program text), then you can't execute it.
    Now do "ls -l" on your data file. Is it owned by you? does it have 'r' permissions on it?
    hi again,
    yeah, I did ls-l and I got some table, then thing its executable !!
    isn't it !?
    what is the next step then !?

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    The next step is to post your results and save the interpretation for us.

    You post facts, we analyse and inform.
    AndiPersti likes this.
    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.

  9. #9
    Registered User
    Join Date
    Feb 2013
    Posts
    6
    Name:  result.jpg
Views: 49
Size:  128.8 KB

    here is it

  10. #10
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,340
    Are you saying that you unzipped "c code.zip" and found an executable, and then tried to run it?

    FWIW, you should create subdirectories before unzipping files. In your home directory, there are a large number of "dot-files" (do "ls -a" to see them). Trashing these by unzipping some errant zip file can effectively trash your account.

    Try these
    Code:
    $ file main
    a.out: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.15, not stripped
    $ uname -m
    x86_64
    Unless the architecture is the same, you're unlikely to succeed.

    Also, if main didn't come from the zip file, where did it come from?

    Ordinarily, it should be the result of some compiling, like
    gcc -o main prog.c

    Show us how you came to have main in your directory.
    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.

  11. #11
    Registered User
    Join Date
    Feb 2013
    Posts
    6
    Are you saying that you unzipped "c code.zip" and found an executable, and then tried to run it?
    yeah, exactly. I put my zip code in home, then extracted both files. finaly, Im trying to run..

  12. #12
    Registered User
    Join Date
    Feb 2013
    Posts
    6
    ohhhhh, I guess the problem was with this stupid zip file,,,,
    I removed it and it runs now.
    many thanks for your helps.
    Salem likes this.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stock program
    By akerman in forum C Programming
    Replies: 27
    Last Post: 11-17-2012, 11:05 AM
  2. Stock Program
    By Adrian K'Ski in forum C Programming
    Replies: 15
    Last Post: 06-03-2012, 07:30 AM
  3. Stock system
    By dan.goodridge in forum C Programming
    Replies: 7
    Last Post: 05-21-2012, 04:54 AM
  4. Stock Data
    By bskaer1 in forum C++ Programming
    Replies: 0
    Last Post: 10-16-2010, 11:59 PM
  5. Stock Quotes
    By jmd15 in forum Networking/Device Communication
    Replies: 4
    Last Post: 08-31-2006, 04:35 PM

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