Home

Solaris UNIX Tutorial - Computer Science Home

image

Contents

1. Load module a out is created after successful compilation Executing the a out load module Type a out at the shell prompt and use the output redirection operator to direct the output of execution to an arbitrarily named file time program output Figure 27 shows the contents of the time program output file that is produced cs wpunj edu PuTTY hash z 03 a out gt time program output hash z 03 cat time program output Co240 begins at amp 00 00 AM BUSZ Ul1 begins at 12 00 00 PM MUS101 begins at 3 30 00 PH bash 2 03 B Figure 27 Output can be found in the time program output file 16 Printing the source and the output files Follow identical steps to print the contents of both the source and output files as described in steps 11 and 12 on page 13 for single file programs Editing an existing multiple file project Since all files belonging to the project have been placed in a folder it is convenient to locate them and make necessary changes in a way described in step 10 on page 13 for the simple file project Compiling source files separately When working with large programs with many source files it is often advantageous to compile each source file separately Using the rm command we have removed the a out and time program output files Then we use the compile only c option of the g command to produce object modules from the two source files See Figure 28 x zt cs wpunj edu PuTTY Siz ba
2. and then press the Enter key The system displays the pico editing screen within the PuTTY window as shown in Figure 6 below Note that the file name helloWorld cpp 1s displayed in the title bar of the pico editing window The pico text editor is a menu driven editor where the menu is displayed at the bottom of the screen The symbol in the menu means the holding down of the Ctrl key thus c means holding down the Ctrl key and then pressing the letter c key cs wpunj edu PuTTY UW PICO tm 3 5 File helloWorld cpp Modified Prey Pq as Cur Text Cur Pos Next Po ME Uncut Text To Spell Figure 6 The pico editing screen within the Putty window Entering the C source code for the helloWorld cpp program Type in the six lines for the helloWorld cpp program as shown in Figure 7 below a cs wpunj edu Pull BE UW PICO tm 3 5 File helloWorld cpp Modified include iostream H gt int maini 1 i cout lt lt Hello World lt lt endl return D k Get Help We Writeout W Read File W ma Cut Text E Cur Pos Exit am Justify a Where is Wi ai Uncut Text To Spell Figure 7 The source code for the helloWorld cpp program has been entered 2i saving the helloWorld cpp program to disk The source code you just entered is temporarily held in the buffer To save it permanently on disk press x Ctrl x the pico editor asks you if you want to Save modified buffer as shown in Figure 8
3. local protfile drwxr xr x hus he students public html bash z 03s B Figure 12 The s 4 displays more information about what are stored in a folder Creating a new folder with the mkdir command In a programming class such as CS240 or CS342 you are required to complete many programming projects and each of these programming projects may consist of multiple files It is therefore highly desirable to store files belonging to a particular project in a separate folder where they can be easily and quickly located The mkdir command allows you to create new folders in your current working directory as illustrated below Let s try to create a new folder named programming project 1 in the current working directory home students bushg Type mkdir programming project 1 at the shell prompt and press the Enter key as shown in Figure 13 E cs wpunj edu PuTTY Sele hash z 035 pwd homer st udentas hushq local login public html helloWorld cpp local profile local cshre programming project l bash 2 03 B Figure 13 the mkdir command To see if the new folder has indeed been created we continue in Figure 13 and enter s at the shell prompt the system lists all the file and folder names as shown and the new folder programming project 1 is indeed in the list Opposite to mkdir is the rmdir command which removes an existing folder The usage of rmdir is discussed in the Appendix Moving between directories with the cd comma
4. cpp respectively Note that you may open three pico windows running three separate pico processes in the same manner that you opened your first by logging in the UNIX multiple times This way you can work simultaneously with all three windows for three different files which is very convenient especially during a debugging session oo cs wpunj edu PuTTY SE UW PICO tm 3 5 File time h Modified class timei public timer default constructor timer rint h int m int s f f constructor oid setTimerint h int m int zs Wold displayTimeil int hours tr 0 23 int minutes f 0 59 int seconds f 0 59 may Prey Po WB Cut re Cur Fos ay Next Po WEE Uncut Te To Spell Figure 23 Source code for the time h file 14 m cs wpunj edu Pull UW PICO tmi include lt iostream h gt include time h time t imei 1 hours 12 minutes seconds H time timerint h 1 int m hours minutes seconda H Wold time setTime fint H 1 hours hh minutes Seconds Iri e F aid time displayTime i i court lt lt x xad zal hours 11 i minutes lt 10 Seconds lt 10 houra gt Llej Read Fil Where is finclude lt iostream h gt Hinclude rime nh int mairi Lime t1 tz tL1l setTime 6s cout a ti displayTimer cout lt 4 t2 displayTimer cout lt lt t3 displayTimerr cout lt lt endl t3115 O Oj int m 30 O in
5. dependency instructions in a description file in the current directory By default this file 1s called makefile or Makefile Options q Query return 0 if file 1s up to date non zero otherwise 21 Appendix II Useful UNIX Shell Command Line Key Strokes The following key strokes are to be used in the command line operations only The same key strokes in different environment e g in the pico or vi editor may invoke totally different responses Ctrl D Ctrl H Ctrl R Ctrl U Ctrl W Ctrl C logging out of a UNIX session equivalent to typing logout or exit at the shell prompt and then pressing the Enter key Deleting a character to the left of the cursor in the command line after the shell prompt same as pressing the Backspace key Redrawing the current command line Deleting or killing the entire command line Deleting a word to the left of the cursor in the command line Terminating the execution of a shell command For example when you typed man ls at the shell prompt the UNIX displays in lengthy detail about the usage of the Is command You may press Ctrl C to terminate the screen display as soon as you ve obtained the needed information about the ls command The arrow keys o Top Scrolling backward through previously entered commands at the shell prompt in a sequential manner All previously entered commands are stored in the buffer o Down Scrolling forward through commands st
6. zm cs wpunj edu Pull DEAR UW PICO tm 3 5 File helloWorld cpp Hodified finclude ziostream h int mairi 1 cout lt lt Hello World lt lt endl return OU Save modified buffer ANSWERING Ho WILL DESTROY CHANGES Figure 8 Pico editor asks if you want to save the buffer your program Pressing Y pico responds by requesting confirmation that the file is going to be stored under the filename helloWorld cpp Press the Enter key to confirm pico returns control to the UNIX shell with the shell prompt bash 2 03 shown in Figure 9 below of cs wpunj edu PuTTY UW PICO tm 3 5 File helloWorld cpp Hinclude lt iostream h gt int maint cour lt lt Hello World lt lt endl return Wrote 6 lines bash 2 03 B Figure 9 Back to the shell interface At this juncture you may be wondering where 1s the file stored and how you are going to be able to find it so that you can compile and run it It turns out that the helloWorld cpp file has been saved to your current working directory or folder the folder that the UNIX system assigned to you at the time you logged in Similar to Microsoft Window s file system you may create many folders and store your program in any of these folders as you wish So before we show you how to compile and run the program we introduce and demonstrate a few frequently used file related commands including pwd displays the current directory or folder
7. Display today s time and date Display information about individual users To upload and download files Terminate a running command or a process Print the content of a file Display information about a command Change password Show processes Write to others online Connect to another system Display who are currently logged in 19 II Detailed Syntax and Usage of a Few Commands Frequently Used in CS Programming Classes e s options names If no names are given all files and folders in the working directory are listed If names are provided if the name 1s a folder name all files in the named folder are displayed if it 1s a file name the information about the file is displayed The most useful options are listed below Note that an option is an upper or lower case letter preceded by a hyphen if you specify more than one option then only a single hyphen preceding the first option is needed Options List all files including the hidden files those preceeded by a when displayed F List all file and folder names and append a to folder names to executable file names such as a out and to symbolic links i List inode of each file l Long format listing including file access permissions ownership size creation or modification time etc T List files in reverse order by name and by date t List files by modification time newest first e my options source target Move files and dire
8. E and puTTy WS_FTP LE is a file transfer utility that facilitates the file transfer between a home PC and the Department s UNIX server puTTy is a Telnet program that facilitates remote access to our UNIX server from a home PC Both WS_FTP LE and puTTy are shareware that can be downloaded from the Internet free of charge for educators and students We first provide the downloading and installation procedure of these two software packages We then demonstrate in detailed steps how a single file and then a multiple file program are entered compiled and executed in the Solaris UNIX environment Note Although the default settings for PuTTy display white text on a black background in this document we use black text on a white background in order to save ink II Downloading and Installation of WS_FTP LE and puTTy Downloading the putty software you may first use the google search engine to look for a putty download site by entering putty as the search word Google displays the sites where a free download is available For example the following is the first among many sites PuTTY a free telnet ssh client Open source SSH client with remote file copying support Win32 Intel and Alpha www chiark greenend org uk sgtatham putty 5k Cached Similar pages Click on the hyperlink to go to the site and follow screen instructions to download the putty exe software Note that you may want to first create a folder to store the putty softwa
9. Only on clean exit Figure PuTTY Configuration Window 2 Entering the telnet connection information Enter cs wpunj edu the IP address of our UNIX server in the Coach House in the Host Name box then select SSH protocol as shown Click on the open command button the cs wpunj edu putty login screen appears as shown below you are now connected to the UNIX server and it prompts you to enter your username Before you proceed to login you may exercise the option of configuring the putty session e g change background and text color etc by clicking the PuTTY icon at the upper left corner and clicking on change settings In the PuTTY configuration window click on Colors o gt cs wpunj edu PuTTY Figure 2 The UNIX login screen Entering the UNIX login information of the user Enter your username where bushg is entered as shown in Figure 3 your username is provided by your instructor it usually consists of your last name plus the first character of your first name If your last name contains 8 or more characters then your username is the first 8 characters of your last name Since UNIX is case sensitive all letters in the username must be entered in lower case i cs wpunj edu PuTTY DEAR login as bushy Note Do not use telnet to log onto Whitestar Use a SSH client like PuTTY The telnet port will NOT be closed but it is highly recommended to use SSH Any problema experienced while using Te
10. Sun Microsystems Solaris UNIX Student User Manual Release 2 02 Spring 2006 Erh Wen Hu amp Marvin Kiss Table of Contents I LE NEU ENDE ERR Om 2 II Downloading and Installing WS_FTP LE and PUTTY sees 3 III Using PuTTY to log onto the UNIX server IE E Dui oru us n M 4 2 Entering connection informato ucucuosceter oin iienaa n UR x exe VES pev V2 iU rau OX HAE TERM UI bra ran eO dide 4 3 Entering UNIX login information ssesssseeeeeennnnennne nennen nennen n nnn n nnn nennen ees sensns nnn enn 5 d Changing your DOS SUVOEG en eeetod tesotimocet ie eio ov Robbe eue doner odisti ua iniiis beventedeseagesegneotdeaaseruvatetents 6 IV A Single file C Project I Launching the pico text CU f oaoocsibesdsideniosnphten naea even sttoeneaudendaoneshandanieagesnaneneasanieommeaanaes J 2 Entering the C source program eeesssssssssssssseeetereressssssssssseeecteeeeessssssssssseecetrereeosssssssssseseeeeosssses 7 De Saving NC so rce prodral osiresisnociscnini sasini eiiie oaeiai Saaie GUESS dE aanihin ariris 8 4 Finding where you are with the pwd command eeeessssssssseseseeeeee nnns 8 5 Displaying contents of working directory with the Zs command ccccceecccceeeceeeeeeeeeeeeeeeeeeeeeeeeeees 9 6 Creating a new folder with the mkdir command sssssssssssss n eene 10 7 Moving between different di
11. at cd chmod cp file head In Is mkdir more pwd rm rmdir tail WC Join files or display the contents of a file Change directory Change access mode on files Copy files Determine a file s type Displays the first few lines of a file Create file aliases List files and directories Create or make a directory Display contents of a file by screenful Move or rename a file or a directory Print or display current working directory Remove files Remove directories Display the last few lines of a file Count lines words and characters 1n a file Programming Commands cc g lex make yacc Compile and link a C program Compile and link a C program with the gnu compiler Perform lexical analysis of a file Manage versions of a large programming projects Convert a file containing context free grammar into tables for subsequent processing 18 Text Editors or Text Editing Commands cut pico Sort VI Select column of a file for display A simple and easy to use menu driven text editor Sort or merge files A command driven full screen text editor popular among professionals Searching Commands egrep fgrep find grep Extended version of grep Search files for literal words Search the system for file names Search files for text pattern Miscellaneous Commands cal clear date finger ftp kill lp man passwd ps talk telnet who displays the monthly calendar clear the screen
12. ctories around on the system or to rename them as illustrated below Source target Result File name Rename file as name File Existing file Overwrite existing file with source file Directory name Rename directory as name Directory Existing directory Move directory as a sub directory of existing one One or more file Existing directory Move all files to existing directory Options i Inquires prompt for a y yes response before overwriting an existing target e rm options files Delete one or more files in a directory To remove a file one must have write permission in the directory that contains the file but one needs not have permission on the file itself Options f If file is a directory or folder remove the entire directory and all its contents including subdirectories So use it with care 20 e chmod options mode files Changes the access mode of one or more files Only the owner of a file or a privileged user may change its mode Create mode by concatenating the characters from who opcode and permission Who 1s optional 1f omitted default 1s a choose only one opcode Who u User g Group O Other a All default Opcode Add permission Remove permission Assign permission and remove permission of the unspecified fileds Permission r Read W Write X Execute Examples Add execute by user permission to file chmod u x file e make options target Update one or more targets according to
13. e download can proceed Again the downloaded file may be stored in a pre created a folder or simply in the root directory of a drive of your choice To install WS FTP LE simply double click the downloaded file If the installation is successful the system displays the WS_FTP icon on the desktop if not Just copy it from the Windows program menu as shown below To launch an FTP session simply double click on the icon The detailed operations of FTP will be discussed later in the manual ie The WS_FTP LE icon WS9 7P951Ehk II Using PuTTy The following demonstration shows the steps needed to connect a remote computer such as your home PC to the Solaris UNIX server maintained by the Department of Computer Science William Paterson University l Launching the PuTTY telnet software Click on the putty exe icon assuming the putty exe icon is displayed the desktop The puTTY Configuration dialog box appears PuTTY Configuration Category E Session Basic options for your PuTTY session Logging Specify your connection by host name or IP address E Terminal Host Name or IP address t aa Ball Protocol Features EXE x E Window O Raw OTelnet OAlogin SSH Appearance Load save or delete a stored session Behaviour Translation Selection Palau Default Settings El Connection save Save ES Hlaain SSH Auth Tunnels Saved Sessions p Close window on exit 4gs O Away Never 5
14. e in the public domain We also demonstrate the use of a few frequently used UNIX commands such as mkdir makes or creates a directory or folder cd changes the working directory or folder pwd displays or prints the working directory or the directory you are currently in and s lists the contents of a directory Since almost all real world programs are developed and compiled as separate files we provide in section V a demo which shows in detailed steps how a multi file software project is compiled linked and executed For the convenience of users we provide in section VI a list of UNIX commands frequently used by beginning level software developers IV 2 A single file C project We demonstrate below in detailed steps how a single file program helloWorld cpp 1s entered into the system via the pico editor a UNIX utility or command and then compiled linked and executed using the famous gnu C compiler via the g command Launching the pico text editor The main reason we choose the pico editor for entering and editing C source code is its ease of use through a well organized set of menus It is available in the public domain for free download To launch the pico editor simply type pico at the UNIX prompt bash 2 03 on our system it may look different on other UNIX systems and the name of the file helloWorld cpp in this demo Note that unlike Micorsoft Visual C no embedded space is allowed in a filename in UNIX
15. ect 20060204 22 w Dinfo 1 Proiect 20060204 Rename E i i zl E E si d e f 9 h i Peas k 1 P bd LP LIJ LIJ LI LIJ LIJ LJ v C ASCII Binary Auto 150 Opening ASCII mode data connection for file list Received 1688 bytes in 0 2 secs 88 40 Kbps transfer succeeded 226 Transfer complete Close Cancel Logwnd ptions The WS FTP LE cs wpunj edu window consists of 2 two panes The pane on the left displays the disk drives directories and files of your Local System your home computer for example the pane on the right shows the directories and files of the Remote System 23 our UNIX server in the Coach House You may select any file or files in any folder on any drive of your local PC and transfer them uploading to any of your folders on the UNIX server You may also transfer any of your files from the UNIX server to your local PC Once the files are selected the transfer is effected by clicking the arrow icon in between the two panes In addition to file transfer the WS_FTP LE is capable of performing many other functions for you by clicking on appropriate buttons These buttons including chdir mkdir exec rename delete and refresh are grouped into a panel on the right side of each pane of the WS_FTP LE cs wpunj edu window The use of these buttons is rather intuitive so no attempt is made here to discuss it further 24
16. ess the Enter key Holding down the Ctrl key and pressing D is another method 13 A Multiple file C Project Creating a folder to store all files belonging to the program In the below demonstration we will use a time program to show how a multiple file program is dealt with in the Solaris UNIX environment The time program displays time of the day in standard format The program is composed of three files the time h file a user defined header file that defines the interface of the time class the fime cpp file which implements all the functions defined in the firme class and the main cpp file the driver file that makes use of the time class As discussed in section IV it 1s convenient to create a separate directory used exclusively for the storage of all files of a program Using the mkdir command we create a new folder and name it time in the working directory of bushg Figure 21 shows the time folder has been created within its parent bushg folder and through the use of cd command the time folder has been made the current working directory cs wpunj edu PuTTY Sel hbhash z 03 pwd homer studenta hushg hash 2 03 mkdir time bash 2 03 cd time bash 2 035 pod homer students busha time bash 2 03 B Figure 21 Using the pwd command Entering files Using the pico editor we separately entered the code for the three files mentioned above Figure 22 through 24 displays the code for the time h time cpp and main
17. for editing Enter the addition line as illustrated 1n Figure 18 Compile and link the program again with the g command and execute the a out load module The screen shows the new result of execution with two output line lines AII these steps are displayed in Figures 18 and 19 RO cs wpunj edu PuTTY KB UW MEE 3 5 File helloWorld cpp Modified include lt iostream h gt int maini 1 cout lt lt Hello World lt lt endl cour lt lt A Greeting From C lt lt endl fl return E Get Helpe Wroitecutfd Read UE Prev Pg BA cut ees Cur Fas ani Justify Wu Where is Next Po wi Uncut Te To Spell Figure 18 the pico editing window where a new line has been added 12 11 12 13 cs wpunj edu PuTTY Wrote 7 hash 2 03 g helloWorld cpp bash z 03 a aut Hello World A Greeting From C bash z 033 B Figure 19 Output from the edited program Printing the C helloWorld cpp source program To print the source code is simple Just type the Jp line printing followed by the name of the file helloWorld cpp This command will print the file on the default printer Colossus in lab101a Printing the output result As you ve noted in Figures 17 and 19 the outputs are part of the screen display mixed together with commands that you entered and the responses to these commands from the UNIX system One way to separate the outputs from the screen display is to use the redirection fea
18. he password simply type in the UNIX command passwd Note that passwd is actually a UNIX utility for practical purpose we make no distinction between a shell built in and utility command in this user manual both will are referred to as commands Also note that the command name passwd is correctly spelled and there is no or in passwd at the UNIX shell prompt cs wpunj edu PuTTY bash 2 033 passwd passud Changing password for bushy Enter login password New password Re enter new password passwd SYSTEM passwd successfully changed for bushy bash 2 03 J Figure 5 Use UNIX passwd command to change password Enter your current login password press the Enter key the system will then ask you to enter the new password which must differ from your current password by at least three characters Also the password must contain at least six characters To confirm your change the system prompts you to enter your new password again Important note it is highly recommended that you memorize your password preferably write it down somewhere for future reference In case you forget your password it will burden the lab administrators to reset your password Just like you the lab administrators are students who have a lot of work to do In section IV we provide a demo on how to enter compile link edit and execute a single file C program using the easy to use pico text editor and the famous gnu C compiler widely availabl
19. lnet will NOT he addressed Thank you bushuglics wpunj edu s password if Figure 3 UNIX login screen where username and password are entered You are then prompted to enter your password As a new user you will be assigned a temporary password As a protective measure the password you entered is not displayed on the screen If the username and password is correctly entered you should see the UNIX screen similar to the one shown in Figure 4 where bash 2 03 is the prompt from the popular Bourne again UNIX shell At the prompt you may enter any UNIX command including those that allow you to enter compile link execute and print the source code and output from your program m cs wpunj edu Pull DE 4 45 5 5 IMPORTANT NOTICE t tktkthkk5t spam filtering is now in effect Mail thought to be spam will be placed in homer cusername Mail Z2PAM Please check and delete SPAM often To check your spam use the following command gt mail f Mail SPAM Any Questions please email Marvin Kiss kissmib5l erizon net or Anthony Stella stellaalf student wpunj edu hush Your data usage Cat cannot open tmp quotas bash 2 03 B Figure 4 Successful login UNIX displays prompt bash 2 03 lt Changing your password As a new user the first thing we recommend you to do is to change your password For security reasons you may want to change your password periodically To change t
20. nd Without a path beyond the scope of this manual that specifies the location of a folder all new files are stored by UNIX in the current working folder So if you just create a new folder and want to store files in it you need to make the newly created folder your working folder and it 1s easily done through the use of the cd or change directory command as illustrated in Figure 14 below RO cs wpunj edu PuTTY bash 2 035 pwd homer students hushg bash z 03 cd programming project l hash z 03 pwd home students bushg programming project l hbash z 03 1s bash 2 03 B Figure 14 The cd command As shown in Figure 14 the pwd command displays home students bushg as the current working directory We then type in cd programming project 1 press the Enter key and then enter the pwd command again The system now displays 10 home students bushg programming_project l as the new working directory Since we have not yet created any new files in it or moved any existing files to it the following ls command results in nothing listed To change the working directory from programmingproject l to bushg the parent folder that contains it simply type at the shell prompt the cd command a space and two dots or periods in a row then press the Enter key as illustrated in Figure 15 The two dots here mean the parent of the current working directory cs wpunj edu PuTTY a E hash 2 03 pwd home s
21. nter s at the shell prompt and press the Enter key the UNIX system displays all the files and folders that have been previously created in the bushg working directory as shown in Figure 11 below Notice the helloWorld cpp we just entered is in the list cs wpunj edu PuTTY hash z 3 ls cse230 local cashrc local profile helloWorld cpp local login public html bash 2 03 B Figure 11 The s command displays all the file and folder names in the current folder There are many names in Figure 11 and there is no way of telling which of these names are associated with files or with folders Modifying the s command with a flag or switch a dash followed by a lower case letter L not numeral 1 where I stands for long or long format the system displays in Figure 12 a whole lot more information including whether the name is associated with a file or a folder the first letter d in the first column of display indicates a folder the size of the files the time when the file or folder was created or last modified etc There are many other flags or switches that can be used to modify the meaning of the s command which are discussed in the Appendix cs wpunj edu PuTTY hbash 2 03 ls 1 total ile drwxr xr x hus he students cs230 rUu r r bus hg students helloWorld cpp rUu r r hus he students local cshrc rU r r hus he students local lodgin rUuU r r hush students
22. ored in the buffer and stopping at the most recentl y entered command o Left Move the cursor to the character on its left in the command line o Right Move the cursor to the character on its right in the command line 22 Appendix III Uisng WS FTP LE Launching WS_FTP LE Double click the WS_FTP LE icon on the desktop copy it from the program menu to the desktop if the icon is not there the system displays the Session Properties dialog box in Figure Al below session Properties General Startup Advanced Firewall Profile Name Se Mew Host Mame Address Icswpunjedu Delete Host Type Automatic detect User ID leh Anonymous Password sr 00000000 Iw Save Pwd Account iC Comment Enter information as shown except you must enter your UNIX login name in the User ID box and your UNIX login password in the Password box Click the OK button the system displays the WS_FTP LE cs wpunj edu window in Figure A2 below WS_FTP LE cs wpunj edu Local System Remote Site M Name Date Chair Name Date 5 psut9532 d11 19951214 15 08 2 A B sopc builder 20051211 23 46 a cs240 20051214 5 TypeLibrary t 19970407 11 13 Ga CS342 20040215 a G cs430 20040510 E c Gj cs480 20020903 2003 20050216 6 F2004 20041217 f 2005 20051101 d Gradebooks 20040504 Gp Hu Curriculum 20031110 Delete programming 20060204 l Refresh d programming p 20060205 Refresh Dirlnfo proj
23. re or directly store it in the root directory of any drive of your choice To install putty simply double click the putty exe file you have just downloaded If the installation is successful the putty icon shown below should appear on the desktop if not just copy it to the desktop from the Windows program menu Double clicking on the putty icon initiates a remote login session to our Solaris UNIX server where one can gain full access to services provided by the UNIX system as will be discussed later in this user manual The putty icon rim Putty exe Downloading the WS_FTP LE software Note that only the LE version which stands for the limited edition version of the software is available free of charge for educators and students Go to the google site and type in the search phrase WS_FTP LE google displays sites where the software can be downloaded For example the following is the one possible site among many others WS FTP LE Reviews and free downloads at Download com WS FTP LE Transfer files over the Internet Review and free download at Download com www download com 3000 2160 1572132 html 22k Feb 2 2006 Cached Similar pages Go to the site and then follow screen instructions to download the appropriate version of the WS_FTP LE software that is compatible with your operating system e g Windows 2000 or XP etc Note that you may be required to prove your student status by completing a questionnaire before th
24. rectories with the Cd command sssssse 10 8 Compiling and linking a C program with the GNU C compiler cccccceecceeeeeeeeeeeeeeeeeeeeees 1 9 Executing the a out load module cccccccccccccccccceceeaeaeeeseeseeeeeeeceeeeeeeeeeaaaaeeeeseeseeeeeeeeeeeeeeeeaasaaaaensees 12 10 Retrieving and editing an existing file eeeeeessssssssssssssseseeee enne eene nene nnn nnn nnne nennen nnns 12 T P ntine the SOURCE prO CLAIM acces veu eio usa eoo dES FUP DEP e eue do Ute aus uden D Eaa a 2 eiiiai 13 I2 Printinge The OUT PU FeSWlE cu soss s ipie feb Qus pede a User dro bu ama Os tes ue dese Oben 13 IN OOO Te oul otihe UNIA CC 13 V A Multiple file C Project 1 Creating a folder to store all files belonging to the project ccc cssssssssseeeeeeceeeeeeeeeeeeeaessesseeeeeees 14 2 Ei I SO UIC lll CS TET DT 14 3 Compiling and linking multiple files ccc cece cccceecesseeeeeeeeeececeeeeeeeeeeaaaaaasessseeeeeeeeeeeeeeeeeaaaaagees 16 4 Executing the multiple file Project ssssssessssssesssesssseeeeeeee en nennen eene nennen n nnn nnn nennen nennen nns 16 5 Printing the source code and output result eeessesssissssssssssseeeee nennen nennen enne nnn nnns 17 6 Retrieving and editing an existing multiple file project eeeesssssssssseeeeeeeen e 17 7 Compiling source files separately sssssssseeses
25. s lists the contents file names and folder names of a directory cd changes directory mkdir makes or creates a new directory or folder within the current folder and mv moves or changes the name of a file or folder Other useful UNIX commands related to your programming classes are discussed and summarized in the Appendix Finding where you are with the pwd UNIX command As discussed above the pwd command displays or prints the current working directory or folder Enter pwd at the shell prompt and press the Enter key the system displays home students bushg as shown in Figure 10 below where the leftmost slash indicates the root directory of the file system home is a folder or subdirectory in the root folder students is a folder for student accounts in home and bushg 1s the login name of a student It is also the default working directory of that student You will get a similar display with your login name as the name of your default folder Clearly you can see that in UNIX files are stored in folders and folders are organized in the tree like or hierarchical order cs wpunj edu PuTTY hbash z 03 pwd hame studentas hushg bash z 03 J Figure 10 The pwd command displays the current working directory or folder Listing contents of a folder with the s command The s or list command lists all the files and folders contained within the current working directory or folder Continue from the previous screen e
26. sh z 035 rm time program output bash 2 035 rm a out bash 2 035 ls main cpp time cpp time h bash 2 035 g c time cpp bash 2 035 g c main cpp hash 2 034 ls Imain cpp main o time cpp time h time a bash 2 03 J Figure 28 Separate compilation of source files The next step is to use the g compiler to produce the a out file from the object files Again we execute the a out file to produce the program output as shown in Figure 29 cs wpunj edu PuTTY bash 2 035 g time o main o hash 2 039 a out Caes begins at amp 00 00 AM BHSz i begins at 12 00 00 PH HUS101 begins at 3 30 00 PM bash 2 03 B Figure 29 Lanking the object modules and executing By now we have covered the basic knowledge and procedures needed to successfully compile link and execute a single file as well as a multiple file C project in the Solaris UNIX environment In the process we have introduced several frequently used UNIX commands such as mkdir rmdir cd pwd ls mv lp pico and g In the following Appendix we categorize some of the frequently used UNIX commands by their functions We then provide a more detailed description and variations about the usage of these commands 17 Appendix I Frequently Used UNIX Commands I Frequently used commands grouped by their functions and sorted alphabetically based on the book UNIX in a Nutshell D Gilly O Reilly amp Associate Inc File Management Commands c
27. sseessseeeeeeeeeeeene nennen nnn nenne nennen nsn n i rrr nnn nnne nis 17 Appendix I Frequently Used UNIX Commands eeeeeeeeeeeeeeeeeeeeeeeeeeeennennnnn 18 Appendix II Frequently Used UNIX Shell Command Line Key Strokes 2 Appendix HE E sno WS FIP LI suscite Rh SPEO IDEM SER AMEN MM 23 Please forward your comments suggestions to hue 9 wpunj edu or kissm15 verizon net I Introduction This manual is primarily written for the beginning students in CS240 who are unfamiliar with the UNIX operating system The main objective is to enable students to enter compile execute and print their C C software projects in the UNIX environment as quickly as possible To this end the same two simple programs used in our MS Visual C C 6 0 manual the Hello World single file program and the Time multiple file project are used here for demonstration A subset of frequently used UNIX commands and utilities especially those that are used for file management is also introduced Because of its relative ease of use the menu driven pico editor is used for the demonstration instead of the more popular vi and emacs editors used in the industry The wi and or emacs can be learned quickly as soon as students become acquainted with the UNIX environment In order to access our powerful UNIX from a remote location such as from your home it is strongly recommended that the users download and install WS_FTP L
28. t Z int zl Ss Le 1 cc IU ET lt lt minutes lt lt p lt lt seconds lt lt PM AM lt lt endl i Cur Text eli Uncut Te rr T rr T Cur Pos To Spell Prey Po Wext Poy main cpp Oj Z240 begins at T nBUSZ U 1 begins at nMUS101 begins at Cur Pos To Spell MS Cut Text e Uncut Te Figure 24 Source code for the main cpp file 15 In the time folder we now have three files ready to be processed as shown in Figure 25 below cs wpunj edu PuTTY E B E bash z 035 pwd fhome students bhushg time bash z 33 ls Inlain cpp time cpp time h bash 2 03 J Figure 25 Three files are in the fime folder Compiling and linking files To compile and link the three file we have just entered simply type g time cpp main cpp and then press the Enter key Notice that only files with cpp extension appear after the g command the inclusion of the time h header file is implied through the use of the C pre processing directive include time in both the time cpp and main cpp files Similar to a single file project an executable load module a out will be created if there are no compiling and linking errors in the program Figure 26 shows the compilation and linking are successful and the a out is produced in the same time working directory or folder J cs wpunj edu PuTTY hash 2 03 ls time cpp Imain cpp time cpp bash 2 03 J Figure 26
29. t l hash 2 039 mnm helloWorld cpp programming project l bash z 03 cd programming project l hash 2 03 ls helloWorld cpp g helloWorld cpp helloWorld cpp Figure 16 The g command that compiles and links the program 11 10 Should there be any compilation or linkage errors the system will display appropriate error messages which are absent from Figure 16 indicating the executable a out load module has been created in the working directory Typing s at the shell prompt confirms that the a out file is there as shown in Figure 16 Executing the a out load module To execute the a out module simply type a out at the shell prompt and press the Enter key The single line output Hello World is displayed on the screen as expected This 1s shown in Figure 17 below E cs wpunj edu PuTTY DEAR bash z 3 ls a out helloWorld crpp bash z 3 a aut Hello World bash z 033 B Figure 17 After executing a out the output Hello World is displayed Editing an existing file What if you want to edit an existing program that you had previously stored For example you may want to add another line in the helloWorl cpp file such that the program displays an additional line A Greeting From C after the Hello World phrase Simple just type pico followed by the filename AelloWorld cpp and press the Enter key The pico text editor retrieves the stored file from disk and displays it on the screen
30. tudents bhushg programming project i bash z 3 1s home atudenta hushg bash 2 03 fj Figure 15 The cd command Note the above demonstrations allow you to move between a parent and a child directory Since there can be a tree of folders of many levels you may need to go through the above steps repeatedly in order to get to the desired folder A quicker way to get to where you want requires the user to specify the path that leads to the folder A discussion of the path can be found in any UNIX textbook Compiling and linking the C program using GNU C compiler We are now ready to compile and run the helloWorld cpp program Remember that the program file is stored in bushg folder To make sure that the file is there just enter the s command as discussed before The mv command is used to move the source file helloWorld cpp to the programming project folder The cd command is used to change our working directory to the new folder We next enter g followed by the filename and then press the Enter key the GNU C compiler compiles and then links only if there are no compilation or syntax errors the program with other modules referenced by the program to produced an a out file as shown in Figure 16 The a out file also known as the oad module is an executable version of the helloWorld cpp program er cs wpunj edu Pull Hoea local login public html helloWorld cpp local protile local cshre programming projec
31. ture of the UNIX system you may ask the UNIX to send the program output to a separate text file with a name chosen by you This is achieved through the use of the output redirection operator gt as illustrated in Figure 20 Note that the output from the execution of a out has been redirected from the default monitor to an arbitrarily named output result disk file in the current working directory EO cs wpunj edu PuTTY Sl Ed hash z 03 a out gt output result Inasn 2 03 la a out helloWorld cpp output result bash z 3 cat output result Hello World Greeting From C hash z 03 lp output result Figure 20 Output from the execution of a out is directed output result file You may use UNIX command such as cat the catenation command or pico editor to display the content of the output result file You can also use the Jp command to print the contents of the file Notice Never print an a out file since it contains binary data that will be unreadable by humans and result in a great waste of paper and ink The lab procedures presented thus far will enable you to run single file programs found in most of the projects in CS230 some projects in CS240 and other computer courses Since most real world programs consist of multiple files we next discuss with a demo how a multiple file program gets compiled and executed Logging out To log out of the UNIX type either logout or exit at the shell prompt and then pr

Download Pdf Manuals

image

Related Search

Related Contents

  DSC-HX5  TABS  設計監理 建設部 建築課  Valcom SIP Intercom/Doorphones  2015 Windsport Motorhomes Owner`s Manual by Thor    User Manual - Rcvliegshop  24CH DMX DIMMER CONSOLE - Flash  Manuel d`utilisation du Nokia 6260  

Copyright © All rights reserved.
Failed to retrieve file