-
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.
-
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
-
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