Help on Linux commands for a C++ code
Hey guys, noob at linux here
I have some c++ code that i wanna run through linux My program accepts two command line arguments: an iteration count and a “sleep” time. this is my code Code:
//test.cpp my question is how do i run this program in the command line while putting these numbers at the end? (if i need to change any part of my code please let me know). do i need to go into the shell? how do i run it in the shell? another question is how do i take what i see in the shell and copy it to a text file? with that done i need to Find out the process ID of test.cpp, Find out all running processes that are related to the name test, While test is still running in one shell issue a command on the other shell that terminates it. and thats it. Thanx! |
I don't quite understand your question but I'll give it a shot.
Your first step is to copy your program to your linux box. If you haven't done that yet I suggest emailing test.cpp as an attachment to yourself, moving to the linux box, opening a browser and downloading it to the desktop. Once you have the file on your desktop open a shell. type in "cd Desktop" and hit enter. then type in "ls" and hit enter. It should list the files on your desktop, and test.cpp should be there. Next we need to compile your program. To do that type "g++ test.cpp" and hit enter. Hopefully it compiles. If not you have a problem with your code. Once it compiles you'll want to run it. To do this type in "./a.out [arg1] [arg2]" and hit enter (where [arg1] and [arg2] are your arguments you're sending to the program. Hopefully that works as you intended. If everything works well up to this point you will want to direct the output to a file. To do this type "./a.out [arg1] [arg2] > filename" That should take all output that appeared on the screen the last time you ran the program and send it to a file named filename. If you get this far let me know and we'll go over the last bit. |
All times are GMT -5. The time now is 10:35 PM. |