Log in to pe15
- Run the ssh client
Use the values in the table below to connect to pe15.
ssh configuration parameter value protocol ssh ssh version 2 ssh port 22 host pe15.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
(When you are ready for me to check this exercise, please scroll back up to where you entered these commands!)
- Go to your ex directory
cd ~/it244/ex- Create an ex12 directory
mkdir ex12- Go to your ex12 directory
cd ex12Start Up a Script Session
Execute the script command, using the --flush option
script --flushRedirecting Input
- Make sure you are in the ex12 directory
pwd- Copy the program repeat.sh from my course_files/it244_files directory to your ex12 directory
cp ~ckelly/course_files/it244_files/repeat.sh .- Copy the text file foo.txt from the course_files/it244_files directory to your ex12 directory
cp ~ckelly/course_files/it244_files/foo.txt .- Make sure the copy operation worked
ls- Run the program repeat.sh
./repeat.shEnter several lines of text, then type "X" and hit Enter.
This program simply prints whatever input it receives to standard output.
- Look at the contents of foo.txt
cat foo.txt- Run the same program taking input from a file
./repeat.sh < foo.txtrepeat.sh took its input from the file foo.txt and printed each line on the screen.Redirecting Output
- Create a file containing information on those connected to pe15
who > current_pe15.txt- Display the contents of the file you just created
cat current_pe15.txt- Create a file containing a listing of all the files in my home directory
ls ~ckelly > ck_dir.txt- Display the contents of the file you just created
cat ck_dir.txtAppending Output to a File
- Use echo to send a string to a file.
echo foo > lines.txt- Use cat to display the contents of lines.txt
cat lines.txtNotice that the previous contents of lines.txt have vanished.
- Send another line to lines.txt
echo bar >> lines.txt- Use cat to display the contents of lines.txt
cat lines.txtNotice that your first line is still there.
/dev/null
- Use echo to display a string in your terminal session window
echo bletch- Now perform the same operation, but send output to /dev/null
echo bletch > /dev/nullNothing appears in the terminal window since you have sent the string "bletch" into oblivion by redirecting the output of echo to /dev/null.Exit Your Script Session
Use the exit command
exitYou should see a confirmation message confirming that the script is finished, resulting in a file called typescriptBash Script for this Exercise
- Make sure you are in your ex12 directory
pwdIf not, see me.
- Create the script ex12.sh
nano ex12.sh- Write into this file the commands from certain sections above
Enter all commands from the section Redirecting output to the section /dev/null
Do not enter commands from the section Redirecting input
- Save this file
Save and quit.
- Make this file executable
chmod 755 ex12.sh- Test the script
./ex12.shFix any errors you find.
If you have trouble, see me.