Running program in unix

This is a discussion on Running program in unix within the Linux Programming forums, part of the Platform Specific Boards category; I created a program that accepts an input file into the program. When i run it in the window's command ...

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

    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:
    Code:
    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:
    Code:
    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.
    Thanks.
    IDE - Visual Studio 2005
    Windows XP Pro

  2. #2
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,655
    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
    Posts
    14,185
    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:
    Code:
    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, 02:56 PM
  2. Stop program from running twice?
    By Abda92 in forum C Programming
    Replies: 19
    Last Post: 03-17-2008, 02:35 PM
  3. Determaining if a program is running
    By WebmasterMattD in forum Linux Programming
    Replies: 4
    Last Post: 04-09-2002, 05:36 PM
  4. Why is my program running away?
    By badkitty in forum C++ Programming
    Replies: 4
    Last Post: 09-19-2001, 05:27 PM
  5. Running program
    By muffin in forum C Programming
    Replies: 5
    Last Post: 08-30-2001, 11:57 AM

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