Thread: Running program in unix

  1. #1
    Registered User Cpro's Avatar
    Join Date
    Oct 2006

    Running program in unix

    I created a program that accepts an input file into the program. When i run it in the window's command prompt, i type:
    PickBestSort scratch2.txt
    PickBestSort refers to the .exe file of my program, and scratch2 is the input file. When i run it this way it works fine. When i uploaded the files onto a unix machine, i can't run it the same way. I have to type:
    g++ PickBestSort.cpp
    ./a.out scratch2.txt
    to get it to run. So, my question is, how could i get it to run the way i did it in the windows command prompt - if this is possible.

    I use putty to connect to the unix machine.
    IDE - Visual Studio 2005
    Windows XP Pro

  2. #2
    Join Date
    Dec 2007
    Compile with: g++ -o PickBestSort PickBestSort.cpp
    Change permissions to executable: chmod +x PickBestSort
    Run (assuming . is in your PATH environment variable): PickBestSort scratch2.txt

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    That is the way you got it to run in the Windows machine: programname filename. If you mean "hey the current directory isn't in the path", that's true. It usually never is on *nix machines, generally to save you from yourself. If you mean "hey all of a sudden my program is called a.out", well, g++ takes a switch on the command line that tells it what the output should be:
    g++ -o PickBestSort PickBestSort.cpp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Finding Program Running Time
    By pf732k3 in forum C Programming
    Replies: 6
    Last Post: 03-18-2008, 01:56 PM
  2. Stop program from running twice?
    By Abda92 in forum C Programming
    Replies: 19
    Last Post: 03-17-2008, 01:35 PM
  3. Determaining if a program is running
    By WebmasterMattD in forum Linux Programming
    Replies: 4
    Last Post: 04-09-2002, 04:36 PM
  4. Why is my program running away?
    By badkitty in forum C++ Programming
    Replies: 4
    Last Post: 09-19-2001, 04:27 PM
  5. Running program
    By muffin in forum C Programming
    Replies: 5
    Last Post: 08-30-2001, 10:57 AM