Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Other Operating Systems (https://www.askmehelpdesk.com/forumdisplay.php?f=433)
-   -   Linux (https://www.askmehelpdesk.com/showthread.php?t=13220)

  • Sep 29, 2005, 05:38 PM
    jduke44
    Linux
    I am using VI editor at work to try to compile my programs for school in C. When I compile I get the file a.out. When I do this on the school's site I am able to just type a.out in the command line and it runs. They are using AIX (whatever that means). I cannot do that here. It keeps saying no such file. I am using Linux, that is about all I know. Can anyone point me in the direction to be able to run my file after compiling it. I hope I gave you all the info. Unfortunately I am not that familiar with Unix. Thanks. :confused:
  • Sep 29, 2005, 10:47 PM
    LTheobald
    http://users.actcom.co.il/~choo/lupg...c-on-unix.html

    Looks like it's just a case of typing what you would to run a normal program in Linux - a full stop, followed by a forward slash, then the program name. So in your case:

    ./a

    I don't think you need the .out at the end. Also, note the tip in the "Compiling A Single-Source C Program" about how to rename your programs to something more useful than "a.out"
  • Sep 29, 2005, 11:08 PM
    psi42
    Just to add to that:

    1) You do need to type ./a.out, not just ./a (unlike DOS, *nix shells don't do silly things).

    Quote:

    Originally Posted by jduke44
    When I do this on the school's site I am able to just type a.out in the command line and it runs.

    This is (probably) because of the environment variable $PATH, which defines where your shell looks for commands that you type that aren't builtins. $PATH contains a list of directories to search. Either the directory where you compile and run stuff is in $PATH, or $PATH contains the current working directory "." (which is generally a bad idea).

    When you want to run a command that is not in $PATH, you need to specify an absolute or relative path. Since "." denotes the current directory, typing ./a.out tells your shell to execute the file a.out in the current directory.


    Alternatively, you can modify $PATH to include the place where you compile stuff:

    How you set $PATH depends on your shell, but on most (I think all) Bourne-compatible shells you should be able to do something like.
    Code:

    PATH=/usr/bin:/bin:/some/other/path:/path/to/foo
    export PATH

    In your case, you'd want to keep the stuff already in $PATH, so you could do
    Code:

    PATH=$PATH:/path/to/where/your/binaries/are
    export PATH

    Quote:

    They are using AIX (whatever that means).
    AIX is IBM's proprietary UNIX operating system.



    ~psi42
  • Sep 30, 2005, 01:31 PM
    jduke44
    Thanks guys for your help. The admin at work fixed it for me. I was trying to see if I could get an answer before I went home last night. It was to do with the path. As you probably already guessed I don't know much about Unix. I want to learn. This helps my knowledge base if anything. Thanks again.

  • All times are GMT -7. The time now is 03:50 AM.