Log in to users
- Log in to a Windows machine or your own laptop
Enter your Unix username as the account name. Then enter your password.
- Run the ssh client
Use the values in the table below to connect to users.
ssh configuration parameter value protocol ssh ssh version 2 ssh port 22 host users.cs.umb.edu user name your Unix username Authentication method password
- Enter your password
A dialog box will appear on the screen into which you must type the password for your Unix account.
Directory for this Exercise
- Go to your ex directory
cd ~/it244/ex- Create an ex23 directory
mkdir ex23- Go to your ex23 directory
cd ex23Start Up a script Session
Execute the script command, using the --flush option
script --flushtest with Numbers
- Use test with the -eq (equality for numbers) operator
test 4 -eq 5; echo $?Since anything other than 0 as an exit status signals failure, this means that the equality test has failed.
- Use the -eq operator with the same number on both sides
test 4 -eq 4; echo $?Since 0 means success, this means that the expression evaluated to true.
- Use test with the -ne (not equal for numbers) operator
test 4 -ne 5; echo $?0 means true.
- Use -ne again
test 4 -ne 4; echo $?1 means false.
- Use test with the -gt (greater than) operator
test 4 -gt 5 ; echo $? test 5 -gt 4 ; echo $?- Use the -ge (greater than or equal to) operator
test 5 -ge 4 ; echo $? test 5 -ge 5 ; echo $?- Use the -lt (less than operator)
test 4 -lt 5 ; echo $? test 5 -lt 4 ; echo $?- Use the -le (less than or equal to) operator
test 4 -le 5 ; echo $? test 4 -le 4 ; echo $?test with String Comparison Operators
- Use test with the = (string equality) comparison operator
test foo = foo ; echo $? test foo = bar ; echo $?- Use test with the != (string not equal) comparison operator
test foo != bar ; echo $? test foo != foo ; echo $?test with Single String Operators
- Use test with the -n (length greater than 0) string operator
test -n foo ; echo $? test -n "" ; echo $?- Use test with the -z (length is 0) string operator
test -z "" ; echo $? test -z foo ; echo $?Exit Your script Session
Use the exit command
exitYou should see a confirmation message confirming that the script session is finished, resulting in a file called typescript. I will look at the typescript file, along with the other files in your directory.arg_test.sh
- Make sure you are in your ex23 directory
cd ~/it244/ex/ex23- Using your favorite editor create the script arg_test.sh
#! /bin/bash # # responds with the number of the arguments given # to this script if test $# -eq 0 then echo You entered no arguments fi if test $# -eq 1 then echo You entered 1 argument fi if test $# -eq 2 then echo You entered 2 arguments fi if test $# -gt 2 then echo You entered more than 2 arguments fi- Make sure you are in your ex23 directory
cd ~/it244/ex/ex23- Re-Start Your script Session
Execute the script command, using both the --flush option AND the --append option
script --flush --append- Change the permissions on arg_test.sh to make it executable
chmod 755 arg_test.sh- Test the script several times
./arg_test.sh ./arg_test.sh foo ./arg_test.sh foo bar ./arg_test.sh foo bar bletch- Notify me when you have finished this script
Exit Your script Session
Use the exit command
exitYou should see a confirmation message confirming that the script session is finished, resulting in a file called typescript. I will look at the typescript file, along with the other files in your directory.