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 ex22 directory
mkdir ex22- Go to your ex22 directory
cd ex22Start Up a script Session
Execute the script command, using the --flush option
script --flushHistory Expansion
- Look at your last 20 command lines
history 20Notice that your definitions of functions appear on a single line, with each line of your original set of commands separated by a semi-colon.
- Rerun one of your previous commands
Pick a command that will not change your current directory.!EVENT_IDNotice that it prints out the command line before executing it.
- Look at your last 10 command lines where you ran ls
history | grep ls | tail- Rerun your last command line that used echo
!ecBrace Expansion
- Create some files using braces
touch test{1,2,3,4,5}.txt- Look at the files you just created
ls test?.txt- Create some additional files using braces
touch {foo,bar,bletch}.txt- Display all the files you created
ls *.txtTilde, ~ , Expansion
- Display the value of tilde
echo ~- Use tilde to display the address of my home directory
echo ~ckelly- Use tilde followed by a string that is not a Unix ID
echo ~xxxBash cannot make any sense out of this expression, so it doesn't try.
- Use ~+ to display the address of your current directory
echo ~+- Use ~- to display the address of your previous directory
echo ~-Arithmetic Expansion
- Create two numeric variables
a=3; b=6- Display the values of these new variables
echo "a = $a, b = $b"- Use these variables in an arithmetic expression
echo $(( $a + $b ))- Use these variables in another arithmetic expression
echo $(( a - b ))Notice that you did not need to put dollar signs ($) in front of the variable names.
- Use these variables in still another arithmetic express
echo $((a*b))Notice that you do not need to use spaces to separate any of the elements of the expression.
- Create one last arithmetic expression
echo $((b/a))Command Substitution
- Use command substitution to see the permissions on the python executable file
ls -l $(which python)- Use command substitution to set the value of a variable
now=$(date)- Display the value of this new variable
echo $nowPathname Expansion
- Display all files ending in ".txt"
ls *.txt- Display the "test" files created earlier
ls test?.txt- Display the first two "test" files
ls test[12].txtExit 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.Bash Script for this Exercise
- Make sure you are in your ex22 directory
cd ~/it244/ex/ex22- Create the script ex22.sh
nano ex22.sh- Write into this file the commands you used in some of the previous section
Include Unix commands from the section Brace Expansion, to the section Pathname Expansion. Do not put the commands from the History expansion section in this script.
- Save this file
Save and quit.
- Make this scipt executable
chmod 755 ex22.sh- Test the script
./ex22.shFix any errors you find.
If you have trouble, see me.