Table of Contents

Part 2

Entries

October 20th, 2011

I have decided to install Ubuntu, Linux on my personal laptop at home. In the process of installing the operating system, I could not get the wireless network card to function. Today, I took my laptop to class and had my professor take a peek at it. I learned how to install a device driver in Linux using a terminal screen. This was of significance to me because I was able to take the fundamentals of what I have learned this semester and apply it in the “real world”. Although I was not able to complete the necessary process on my own, the help I received was priceless. Come to find out… it was not a driver issue in the end. It ended up being an issue of the kernel not seeing a needed file. Once we copied the necessary file to the proper location the wireless card took off and started to function properly. On a side note… I am enjoying the new operating system!

October 27th, 2011

Today I learned how the Unix/Linux shell terminal is really a CLI or command line interpreter. It forced me to see the terminal session slightly differently. I found it really interesting that the command prompt in a terminal session is really a CLI program waiting for me to enter a command and interact with the operating system. Once a command has been entered it is then up to the command line interpreter to interpret the command and execute it. This was significant to me because it connects the dots if you will with the statement that a command line prompt is where our Unix spells are cast. It finally makes sense!

October 17th, 2011

Today We created a small shell script using Unix/Linux in my Computer Essentials class. We used a Unix/Linux based operating system called Ubuntu. This operating system was downloaded and installed on a USB flash storage device. When the computer system boots the the USB flash device, the Ubuntu Unix/Linux operating system loads. The professor then instructed the students to open a terminal session and enter the text editor, nano. Once in nano, we were instructed to enter a basic shell script to demonstrate the programing capabilities of the Unix/Linux operating system. This was significant to me because once that terminal session opened up and the command prompt appeared, it was off to the races. It was great to know how the text editor operated and also the basic Unix commands to help navigate the process.

October 10th, 2011

Today I spent some time trying to understand the difference between a compiler and interpreter in Unix/Linux. I found that an interpreter's purpose is to interpret a command to machine language or binary. A compiler also interprets a human based code to machine language but also creates an executable file. The purpose of the executable file is to make a program code file run. I believe an interpreter will process the code line by line, whereas a compiler will run a source code as a separate program. I still have quite a bit to understand about both the compiler and interpreter but I really felt like the process is starting to click.

UNIX Topics

Part: 2

Keywords:

  1. VI Text Editor
  2. Insert Mode
  3. Command Mode
  4. Foregrounding a Process
  5. Multitasking
  6. Signals
  7. Job Control
  8. Tab Completion
  9. Viewing
  10. The UNIX Shell
  11. Copying
  12. Creating

Keyword 1

Vi Text Editor:

Vi text editor is a “screen-oriented” text editor that allows you to create text files and also programing files for bash or C. It operates within two different types of modes; Insert mode, and Normal Mode. To open vi text editor you need to enter “vi [filename]” at the command prompt in the terminal. Once vi opens, by default, you are in normal mode. Normal mode will allow you to use keyboard shortcuts to edit or perform command operations. Insert mode will allow you to physically edit or create a text body. Vi Text Editor's main advantage is that because command operations and the actual text editor work independently from each other, it allows the user to always have there hands on the keyboard. Vi was developed by Bill Joy in 1976, and was actually called “ex” at that time. Ex version 1.1 was released in March of 1978 and was not given the name we know it by today, vi, until version 2.0 was released in 1979 by Second Berkely Software Distribution.

Keyword 2

Insert Mode:

Insert mode or “input mode” as it is referred to, works as the actual text editor or word processor in vi. Once this mode has been initiated, the user can insert and edit text as necessary. When you open vi text editor, by default, you are placed in Command Mode. To initialize Insert Mode from command mode, the user has twelve different options to select from. The only difference in these twelve options is where the cursor will show up in the text body. Below I have documented six of the most common possibilities.

Initializing Insert Mode from Command Mode in Vi Text Editor:
 
press:
      a = changes to insert mode, after cursor position
      A = changes to insert mode, end of current line
      i = changes to insert mode, before cursor position
      I = changes to insert mode, start of current line
      o = changes to insert mode, below current line
      O = changes to insert mode, above current line

Once Insert Mode has been initialized and your cursor has been inserted for text editing in the text body, vi text editor is now in word processing mode. At this point pressing “a” will result in an “a” being typed into the text body. Anything entered into the text at this point is being directly inserted into the editing buffer of the program and you will know you're in Insert Mode because the word “INSERT” will appear at the bottom of the text editor. To get back to Command Mode from Insert Mode you simply just press the “esc” key on the keyboard. You will notice that the word “INSERT” will then disappear from the bottom of the text editor and your ready to prompt a command.

Keyword 3

Command Mode:

Command Mode in the vi text editor is where the keys typed are interpreted as commands. By default the vi text editor starts in Command Mode. In insert mode the typed key or text is directly added to the editing buffer of the program, and each key typed will be displayed in output, exactly the way it was typed. In command mode this is not the case. When the vi text editor was created, typical peripherals, like a mouse, where not used. So without a mouse, a system needed to be developed that would provide the user with access to commands and text editing, using one keyboard and the same keys. Command mode is the system that allows the user to do this. Command mode is entered by pressing the “esc” key on your keyboard. You will know that you are in command mode when the word “INSERT” is missing from the bottom of the text editor. In insert mode, pressing the keys: “dd” would result in the output on the screen to display the letters “dd” in your text body. When in command mode, pressing the keys: “dd” would not result in displaying the “dd” letters in the text body, but instead, “dd” will be interpreted as a command to delete the entire line your cursor is on. Command Mode has numerous commands prompted by typed letters or keys on the keyboard. This mode allows you to save your work, delete or copy line text, decide where the text cursor displays, and exit the program. Command mode and insert mode existing side by side and working together is what makes the vi text editor program a strong word processor. Without both mode's the program would not function efficiently and would probably not be used in today's world.

Keyword 4

Foregrounding a process:

Foregrounding a process in the Unix/Linux shell is part of the multitasking ability the operating system has when running processes. There are two ways to run a process in UNIX/Linux; Foregrounding a process, and backgrounding a process. Foregrounding processes are different from backgrounding processes, in that some foreground processes provide an interface for the user to interact with the process or program and most importantly, only one foreground process can be executed and completed at a time. Starting a foreground process only requires the user to type a command at the shell prompt. For example, the command “ls” is a process that will list all files in the current working directory. When “ls” is typed at the command prompt, as a user, you have just commanded that process to run in the foreground and you will not be able to enter another command until “ls” has finished its execution. While most commands are best suited for executing in a foreground environment, sometimes you will run a process that runs indefinetly until commanded to stop. This is why Unix/Linux is such a powerful multitasking operating system and also why backgrounding and foregrounding a process is so vital. In the example below a process was commanded to run from the foreground. The “&” symbol after the process will start the program in the background of the operating system. To bring the running program to the foreground, the command “fg” needs to be entered at the prompt. This will immediatly bring the running process to your foreground. In the example, the process being run is a chat bot. This process will run indefinetly until the user terminates the program. Because it will continue to run on its own and a foreground process can only complete one command at a time, the terminal shell will just hang up. To send the process back to the background, the user will need to press “^z”, which will suspend or stop the process and a command prompt will show up in the foreground. At the prompt, the user would then enter “bg”, which sends the running process to the background. One thing to keep in mind while foregrounding and backgrounding processes, is that the foregrounding process always takes priority over the backgrounding process.

lab46:~$ ./bigdaddybot.sh &
[1] 20096                              //--->started running process in background//
lab46:~/ jobs
[1]+  Running     ./bigdaddybot.sh &   //---> Shows Background Process//
lab46:~/ fg
./bigdaddybot.sh                       //---> Process was brought to foreground//
_^z
[1]+   Stopped    ./bigdaddybot.sh     // ---> <ctrl>z suspended the process//
lab46:~/ bg
[1]+ ./bigdaddybot.sh &
lab46:~/ jobs
[1]+  Running     ./bigdaddybot.sh &   //---> Process is now sent back to background//

Keyword 5

Multitasking in Unix:

Unix/Linux, by definition, is a multitasking operating system. There are many different ways that the operating system multitask's, but the best way of demonstrating the multitasking ablility would be through the foregrounding and backgrounding commands. In the Unix/Linux terminal session the command prompt exists in the foreground environment. Processes that are started in the foreground, would need to complete, in the foreground before another command can be initiated. Although this works for a lot of the UNIX/Linux commands, sometimes a process will continue to run, until commanded to terminate. In this situation, the running process will need to be multitasked to the background so that the user will be able to continue working on the foreground. It is important to know that running processes in the foreground, carry priority over processes running in the background. The ability for processes to be sent to the background to run and complete, while the user can be active in the foreground is what forms the backbone of multitasking in Unix. To start a process in the foreground, the only thing the user needs to do is login to there screen session and type a command. To run a process in the background, the user will need to add a “&” after the program or command. Once a process has been sent to the background from the foreground, it will continue to run until commanded to terminate or an encounter of an error. To bring the process back to the foreground the user will have to press “ctrl z”, which suspends the process, and then pressing “fg” will foreground the process. If the user needs to send the same process back to the background, the command “bg” would be typed at the command prompt. Below I have provided a screen session example of backgrounding and foregrounding a process.

lab46:~$ ./bigdaddybot.sh
^z
[1]+ Stopped     ./bigdaddybot.sh 
lab46:~/ bg
[1]+ ./bigdaddybot.sh &
lab46:~/ jobs
[1]+  Running     ./bigdaddybot.sh
lab46:~/ fg
./bigdaddybot.sh
^z
[1]+  Stopped    ./bigdaddybot.sh
lab46:~/ bg
[1]+  ./bigdaddybot.sh &
lab46:~/

Keyword 6

Signals:

Signals in Unix are a very powerful way of killing a process. A signal is by definition, a “asynchronous” notification that tells a process or program to terminate it's execution. This is accomplished by entering a certain key combination at a terminal command prompt, that causes the operating system to send an interrupt signal which will either suspend or terminate a running process. There are many different signals in Unix that all send specific interrupt signals to a program or process, that result in changing the “normal flow” of it's execution. The most common key combinations in the Unix/Linux operating system for sending an interrupt signal are ctrl-c, and ctrl-z. When a process is running, whether it be in the background or foreground, pressing ctrl-c will result in the operating system sending a INT signal (SIGINT) which causes the process to terminate. There are many other signals that will also stop a process, and even some signals that suspend a process. Pressing ctrl-z at the command prompt, while a process is running, will only suspend the process's execution. This is seen best when bringing a background process to the foreground. To complete this task the ctrl-z key combination is pressed at the command prompt to suspend the active process. Only then are you able to enter the “fg” command, bringing the process to the foreground. Signals are a great tool when a process encounters an error while executing. After encountering an error like this the user would not be able to enter a command at the prompt, the screen just seems to be frozen. Pressing ctrl-c, will result in an override kill signal, sent to the process, to terminate itself. Once the signal has been applied by the operating system the process terminates and the user's screen should be ready for a command. In the terminal shell below I have demonstrated a process that causes the O.S. to send a suspend interrupt signal, ctrl-c, to the foreground process, terminating the running program.

lab46:~$ ./bigdaddybot.sh   
_                               ---> Program has started running in the foreground, cursor just blinks...
^C                              ---> Ctrl-c executed,operating system sent a SIGINT kill signal to the process 
lab46:~/                        ---> Program was terminated, command prompt is ready.

Keyword 7

Job Control:

Job control in Unix/Linux can be defined as, and operating systems ability to execute multiple processes or programs at the same time. When using a Unix/Linux terminal, a user will by default, only have one process running at a time. Most commands can be executed by letting the program or process to take control of the terminal and then return control of the terminal back to the end-user when the task or command has completed. This is all done in the foreground of the Unix/Linux shell. However, some processes need time to execute and will not terminate until the process has completed, or the end-user terminates the program. In this situation, if the program or process is running in the foreground, then the terminal will not be available to the end-user until the said process either completes, or is terminated. This is why Unix/Linux uses a “background” command. Executing these types of processes in the background allows the terminal to be used for a different purpose. Foregrounding and Backgrounding is the fundamental core of job control in the Unix/Linux system. It allows the operating system to run a process in parallel with another process. Processes or programs that are running in the background are output to display when the command “jobs” is typed at the command prompt. Below I have started two text editors, nano and vi, in the background. In the foreground, I typed the command “jobs” at the command prompt and the list of running processes in the background is displayed. This is the “job control” environment of the Unix/Linux operating system.

lab46:~$ jobs               --->No jobs listed
lab46:~/nano &              ---> Started "nano" in background
[1] 28171
lab46:~/ vi &               --->Started "vi" in background
[2] 28172
[1]+  Stopped       nano
lab46:~/ jobs               ---> Job Control in UNIX
[1]-  Stopped       nano
[2]+  Stopped       vi
lab46:~/

Keyword 8

Tab Completion:

Tab completion is a utility of command line interpreters (CLI) that automatically fills in partially typed commands. To understand exactly what tab completion does, it is important to first understand what a command line interpreter is. A command line interpreter or CLI, is a program that lets end-users interact with the operating system by entering commands at a terminal command prompt. In Unix the CLI is the terminal session where the end-user is permitted to enter a command. Tab completion is a utility built into the CLI, that allows the end-user to only type a few characters of the command that, followed by pressing the “tab” key, will automatically complete the rest of the command. In a situation where the end-user hits the “tab” key and there are multiple choices to pick from, the user can type a few more characters and press “tab” again to filter the correct command. The tab completion utility is basically a shortcut key that speeds up efficiency when the user is typing a command that is very long.

lab46:~$ ls
Desktop   Downloads   Music   Public   Videos
Documents   examples.desktop   Pictures   Templates
lab46:~/cat examples.desktop

[Desktop Entry]
Version=1.0
Type=Link
Name=Examples
Comment=Example content for Ubuntu
URL=file:///usr/share/example-content/
Icon=folder
X-Ubuntu-Gettext-Domain=example-content

lab46:~/cat e "press Tab"        ---> Pressing the Tab key results in the next line
lab46:~/ cat examples.desktop    ---> cat e, then tab, = cat examples.desktop

Keyword 9

Viewing:

Viewing in Unix, refers to the ability to view the contents of a text file. In Unix the command for viewing a file is “cat”. Typing “cat” followed by the file you want to display to output, will result in the file displaying it's contents in your terminal. It is important to mention that you cannot use this command for a directory file, because a directory file is not a text file. It is only a container for other directories and files. The command “cat” is a program that when executed will send the contents of a text file to your display. Below I have demonstrated the cat program in Unix.

lab46:~$ ls
Desktop   Music   Videos   Templates  Documents
examples.desktop   Bin   Temp   
lab46:~$ cat examples.desktop   ---> we want to display this text file

[Desktop Entry]
Version=1.0
Type=Link
Name=Examples
Comment=Example content for Ubuntu         ---> Using the "cat" program we displayed the file examples.desktop in the terminal
URL=file:///usr/share/example-content/
Icon=folder
X-Ubuntu-Gettext-Domain=example-content

lab46:~$

Keyword 10

The Unix Shell:

The Unix shell by definition is a command line interpreter that creates a end-user interface for the Unix Operating System. So the Unix shell is a command prompt based program that hides the detail of the operating system by using a terminal session to execute commands. There are many different types of Unix shell's that are in use today. The most common Unix shell used is the login shell. This is the shell that is created when an end-user logs in to a terminal session. When you see a command prompt in Unix, it means the shell is ready for a command to be entered. Once you enter the command, the shell interprets the command and is then responsible for it's execution. Some other common Unix shells include sh, fish, C shell, and bash. The terminal session below is a login shell that is executing the “ls” command. The end-user has typed the command at the prompt, and now it is the shells responsibility to interpret and execute the command. Once the command has been executed, if sucessful, will bring up another command prompt or the command will be followed with an error to indicate failure.

lab46:~$ ls                                       ---> Command executed in the Unix shell
Documents   Music   Videos   Templates   Public
Desktop   Downloads   examples.desktop   Pictures   
lab46:~/                                          ---> Command was successful

lab46:~/ ld                                       ---> Command was mis-typed
ld: no input files                                ---> Command failure notification
lab46-~/
lab46:~/ 

Keyword 11

Copying:

Copying files in Unix/Linux is accomplished by applying the “cp” command at your terminal prompt. This command allows you to copy files and place them in another directory file. You can also use the “cp” command to copy one directory to another, by attaching a “-r” to the “cp” command. The proper syntax to copy a file would be; cp (file) (destination). The proper syntax for copying a directory to another directory would be; cp -r (directory) (dest. directory). There are many command attachments you can add to make the copy program achieve various tasks. The “cp” and “cp -r” commands however, are the most commonly used. In the terminal shell below I have demonstrated how to copy both regular files and directory files to a different location. (Note: files in parentheses are indicated as directory files.)

lab46:~$ ls
bill  bin  bob  (other)  test  test2  (tests)  tim  tmp  (unixplay2)
lab46:~/ cp test other    ---> copying the file test to the destination directory, other
lab46:~/ cd other
lab46:~/other$ ls
test                     ---> test is now copied to the directory, other
lab46:~/other$ cd
lab46:~$ cp test tests   ---> copying the file test to the directory, tests
lab46:~$ cp test2 tests  ---> copying the file test2 to the directory, tests
lab46:~$ cd tests
lab46:~/tests$ ls
test  test2              ---> both files, test and test2, have been copied to the tests directory
lab46:~/tests$ cd
lab46:~$ cp -r tests unixplay2  ---> using cp -r to copy the directory tests, to the directory unixplay2
lab46:~$ cd unixplay2
lab46:~/unixplay2$ ls
(tests)                        ---> directory tests has been copied to the directory, unixplay2
lab46:~/unixplay2$ cd
lab46:~$

Keyword 12

Creating:

Creating text files in Unix/Linux can be achieved a few different ways. Files can be created when using a text processing program like Vi or Nano or they can be created using the command “touch” at your terminal shell command prompt. The proper syntax for creating a file using the “touch” program would be; lab46:~$ touch (filename). Once the command has properly been run, the new file will be created within the current working directory. Creating a directory file requires a different command. The “mkdir” or make directory command is required when making new directories. The proper syntax for the “mkdir” command in Unix/Linux is; lab46:~$ mkdir (directory name). This will result in a new directory being created in the current working directory. In the terminal shell below I have created both a regular file and a directory file, using the “touch” and “mkdir” commands. (Note: Directory files are encapsulated within parentheses)

lab46:~$ ls
(Documents)  (bin)  (music)  examples.desktop  (tmp)  program.sh  (videos)
lab46:~$ touch file1                            ---> Created new file1
lab46:~$ touch file2                            ---> Created new file2
lab46:~$ ls
(Documents)  (bin)  (videos)   program.sh            
(music)  examples.desktop  (tmp)  file1  file2  ---> New files have been created
lab46:~$ mkdir test1                            ---> Created new directory, test1
lab46:~$ mkdir test2                            ---> Created new directory, test
lab46:~$ ls
(Documents)  (bin)  (tmp)  (music)  (videos) examples.desktop 
program.sh  file1  file2  (test1)  (test2)                    ---> Two new directory files created
lab46:~$

unix Objective

Objective

Familiarity with the structure of UNIX systems

The structure of Unix Systems is a hierarchical filesystem that uses a command line interpreter to execute processes and programs.

Method

The method I will use for measuring successful academic/intellectual achievement of this objective will be using a terminal session to create text files within directories and then work from the last directory in, deleting all text files and directory files until I have deleted all files created. This method will demonstrate the hierarchical system Unix is. (Note: directory files will be encapsulated within parentheses.)

Measurement

lab46:~$ls
(unix) (Downloads)
lab46:~$ cd unix
lab46:~/unix$ 
lab46:~/unix$ touch file1
lab46:~/unix$ mkdir test1
lab46:~/unix$ cd test1
lab46:~/unix/test1$ touch file2
lab46:~/unix/test1$ rm file2
lab46:~/unix/test1$ ls -l
total 0
lab46:~/unix/test1$ cd /home/user/unix
lab46:~/unix$ ls
(test1)
lab46:~/unix$rmdir test1
lab46:~/unix$ ls
file 1
lab46:~/unix$ rm file1
lab46:~/unix$ ls -l
total 0
lab46:~/unix$ cd 
lab46:~$ ls
(Downloads) (unix)
lab46:~$ rmdir unix
lab46:~$ ls
(Downloads)
lab46:~$

Analysis

This was really a great exercise for using CLI commands to create and delete regular files and directory files. I felt that I did pretty good throughout the measurement. I realized that I couldn't delete a directory file unless the files within the directory where deleted individually. I wonder however, if there may be an issue with the permissions on the files within directories preventing me from deleting the directory before deleting the file within. Next time I might alter the permissions on all created files to see if there might be a more efficient way of completing the objective.

Experiments

Experiment 1

Question

Can multiple test files be copied from one directory to another using the “cp” command?

Resources

http://www.computerhope.com/issues/ch000766.htm

cp manual page, incorporated within Unix/Linux

Hypothesis

Based on what I have read about copying files from the manual page and the web, you should be able to copy as many files as you want from one directory to another. I think the result of the experiment will be that all files I list after the “cp” command will be copied to the directory listed as the dest. directory. The command I will be typing at the command prompt will be as follows: cp (filename) (filename) (filename) (filename) (dest.directory). According to the resource data, there is no limit on the number of files that can be copied from one directory to another.

Experiment

I am going to test my hypothesis by opening a terminal session and attempting to copy four files from my home directory to a directory I have created, called tests. The files I will be attempting to copy are named: test, test2, tim, and tmp.

Data

Success! I started by creating four files using the “touch” command at the terminal prompt. The files I created where named test, test2, tim, tmp. I then created a new directory file within my home directory called, tests. Next I typed the following command at the prompt, lab46:~$ cp test test2 tim tmp tests, and pressed enter. I immediately received another command prompt indicating that the experiment had worked successfully. I changed directories so that the current working directory was tests, and typed the “ls” command. All four files where listed in both my home directory and now in the new directory called tests.

lab46:~$ touch test
lab46:~$ touch test2
lab46:~$ touch tim
lab46:~$ touch tmp
lab46:~$ mkdir tests
lab46:~$ ls
test  test2  tim  tmp  (tests)
lab46:~$ cp test test2 tim tmp tests
lab46:~$ ls
test  test2  tim  tmp  (tests)
lab46:~$ cd tests
lab46:~/tests$ ls
test  test2  tim  tmp
lab46:~$

Analysis

Based on the data collected:

My hypothesis was correct and I didn't run into any shortcomings.

Conclusions

In conclusion… I found that copying multiple files from one directory to another is not only possible, but not very challenging either.

Experiment 2

Question

Using the “cp -r” command can I copy multiple directory files from my home directory to another directory at the same time?

Resources

http://www.itd.umich.edu/itcsdocs/s4148/

cp manual page built into Unix/Linux

Hypothesis

Based on what I have read from the copy manual page in Linux and also the web page listed above I should be able to copy more than one directory at a time. It proved not to be a problem when copying regular text files, so I don't expect that multiple directory files will be an issue either

Experiment

I am going to test my hypothesis by using a terminal session and creating multiple directories using the mkdir command. I will then try and copy multiple directories to one directory within my home directory

Data

lab46:~$ ls
Documents  Downloads  Music  Videos
lab46:~$ mkdir copytoo other tests unixplay2
lab46:~$ ls
Documents  Downloads  Music  Videos  copytoo
other  tests  unixplay2
lab46:~$ cp -r other tests unixplay2 copytoo
lab46:~$ cd copytoo
lab46:~/copytoo$ ls
other  tests  unixplay2
lab46:~/copytoo$ cd
lab46:~$

Analysis

Success! My hypothesis with copying multiple directories worked like a charm.

Conclusions

In conclusion I have discovered that using the cp -r command can copy multiple directories and well as regular files at one time. I also discovered that when using the mkdir command to create new directories, you can also create multiple directories within your current working directory at the same time.

Experiment 3

Question

Can I create an executable program what will launch me into my Alpine e-mail client without typing “alpine” at the command prompt?

Resources

http://linuxcommand.org/wss0010.php

http://www.dummies.com/how-to/content/using-the-vi-text-editor-in-solaris-9.html

Hypothesis

Based on what I have read about shell scripting I should be able to write a shell script that will accomplish my proposed question above. I should be able to use shell script command code to create a password to access my Alpine email client. Using “if” and “fi” statements to provide or deny access to Alpine email inbox. If access is accepted you will be sent to Alpine immediately, if you mistype your password, you will be prompted to enter it again. Failing to enter the password correctly a second time will result in a “Goodbye” message and the program will terminate putting you back to the home directory command prompt.

Experiment

Using Vi Text Editor, create a shell script titled, “e”, that resides in my home directory and when executed, will take me directly to my Alpine inbox.

Data

For this example the correct password = tom

lab46:~$ ./e
Please enter your password: c
Access Denied

Please enter your password: cab
Access Denied.... GOODBYE
lab46:~$
lab46:~$ ./e
Please enter your password: t
Access Denied

Please enter your password: tom
Access Granted
Welcome "userid"... routing you to Alpine email client:

(Alpine login password:  ---> Opens Alpine home page)

lab46:~$

Analysis

It took some time to understand the “if” and “fi” but success was ultimately achieved. The program works perfectly, entering the correct password at the first prompt will launch you into Alpine. Entering in incorrect the first time will prompt you to enter again. If the second password entry is correct you are taken to the Alpine login, and if entered incorrectly you will see a statement telling you “Access is denied…GOODBYE”. Failure to enter the correct password after the second time will terminate the program and put you at the command prompt of your home directory.

Conclusions

There is definitely room for improvement here! When successfully routed to the Alpine e-mail client you are prompted to enter your alpine password as well. It would be nice to have the shell script insert that password for you, being that you already entered a password when prompted by the shell script. I named the file “e”, for e-mail, to shorten the time you would normally use to enter in the six characters of “Alpine”. When executing the program in your default home directory the command to launch the script is: ( ./e ), reducing the number of characters from six to three.