Ask Experts Questions for FREE Help !
Ask
    jduke44's Avatar
    jduke44 Posts: 407, Reputation: 44
    Full Member
     
    #1

    Sep 29, 2005, 05:38 PM
    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:
    LTheobald's Avatar
    LTheobald Posts: 1,051, Reputation: 127
    Ultra Member
     
    #2

    Sep 29, 2005, 10:47 PM
    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"
    psi42's Avatar
    psi42 Posts: 599, Reputation: 13
    Senior Member
     
    #3

    Sep 29, 2005, 11:08 PM
    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
    They are using AIX (whatever that means).
    AIX is IBM's proprietary UNIX operating system.



    ~psi42
    jduke44's Avatar
    jduke44 Posts: 407, Reputation: 44
    Full Member
     
    #4

    Sep 30, 2005, 01:31 PM
    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.

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Linux [ 5 Answers ]

I have a saa7134 TV cards .my linux (kernal 2.6)not configure for this TV cards.pls help me

Need help for Linux boxes. [ 1 Answers ]

How to setup and install the APC power management on Linux boxes? Please help... thks.

Linux to Mac [ 3 Answers ]

How do I get this Linux PC talking to my old Mac? I have Mandrake 9.2 and KDE desktop. The Mac is has a Power PC chip and is running Mac 7.6.1. I have a Belkin router 4 port router hard wired to both of them by ether net. The router feeds my cable modem to both. Since a driver for my HP...

Getting linux [ 1 Answers ]

Hi It's me again. First of all let me thank all the experts that have helped me with my problems. "THANK YOU GUYS" I ran all different sorts of scans on the computer and now it's running faster because all the rubbish files are deleted and the spy sweeper has killed all the spies. One of the...


View more questions Search