Department of Computer Science
Compiling, Linking, and Running C++ Simulation Programs
Using Linux Commands on the CS3 Server
Updated Fall 2016
The CS3 server is a department server and runs under Linux operating system (Red Hat Linux Enterprise Edition 6). The sample C programs are stored in the folder: “/home/jgarrido/psim3”. The compiler used is the GNU C++ compiler, which is the standard (default) compiler on Linux.
You need two utility programs for using CS3:
-SSH client (or Putty SSH client) for remote login to CS3
-SSH File Transfer (or FileZilla) to upload and download files
To connect to CS3, use the Secure Shell Client utility from the KSU software download. Connect to “cs3.kennesaw.edu”. When you are connected to CS3, login by typing your user name, then your password.
On the Linux Operating System, the "bash" shell, is the default shell for Linux. After you login, Linux types a dollar sign ($) as the system prompt. This indicates that the OS is waiting for a command. It is recommended that you create a working directory for your files under your root directory.
The first important step is to start a log session on Linux using the 'script' command with the name of a text that will contain all commands that you use during your Linux session. This command will record your Linux session. Type the following command and name of text file at the '$' prompt:
$ script mysession1.txt
When you are done and before logging out, type the 'exit' command to end the session and close the script text file with the session log. At the '$' prompt type:
$ exit
Use the 'mkdir' command to make a new directory under the current directory, then change to the new directory with the 'cd' command.
$ mkdir mydir
$ cd mydir
Create a working directory for running simulations with the OS models
$ mkdir myos
Copy two files from the /home/jgarrido/psim3 directory to your working directory:
- the simulation model (batch.cpp)
- the psim3c script file
$ cp /home/jgarrido/psim3/batch.cpp myos
$ cp /home/jgarrido/psim3/psim3c myos
In Linux shell, the dot (.) indicates the currently working directory.
Change to the new directory: $ cd myos
Compile and link the simulation model:
$ ./psim3c batch.cpp
Run the model (output on the screen):
$ ./a.out
Run the model and redirect the output to a file
$ ./a.out |tee res1.txt
View the output file
$ more res1.txt
To edit a text file (cpp source file), use the “nano” editor. For example, to edit “hellow.cpp” type the following command:
$ nano hellow.cpp
To transfer the output file to your PC, logout from the Linux shell. Use the SSH File Transfer utility and login.