Changes

Jump to: navigation, search

Tutorial12: Shell Scripting - Part 2

75 bytes removed, 03:48, 17 May 2021
no edit summary
# Issue the following linux command to add execute permissions for your shell script:<br><span style="color:blue;font-weight:bold;font-family:courier;">chmod u+x if-5.bash</span><br><br>
# Run your shell script by issuing: <span style="color:blue;font-weight:bold;font-family:courier;">./if-5.bash</span><br><br>What do you notice? Run several times to confirm that the shell script runs correctly for all mark (grade) categories.<br><br>
# Issue the following to run a checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/myscripts~uli101/week12-check-1</span><br><br>
# If you encounter errors, make corrections and '''re-run''' the checking script until you<br>receive a congratulations message, then you can proceed.<br><br>
# Save your editing session and exit the text editor (eg. with vi: press '''ESC''', then type ''':x''' followed by '''ENTER''').<br><br>
# '''Run''' this Bash shell script again.<br><br>What do you notice this time? <br><br>
# Issue the following to run a checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/myscripts~uli101/week12-check-2</span><br><br>
# If you encounter errors, make corrections and '''re-run''' the checking script until you<br>receive a congratulations message, then you can proceed.<br><br>
:In the next investigation, you will learn to use the '''exit''' statement to '''terminate the execution of a shell script'''<br>if not run with the properly number of arguments and use the '''break''' statement that will '''terminate a loop'''<br>but NOT terminate the running of the shell script.
# '''Add execute permissions''' for this Bash shell script.<br><br>
# Issue the following command (with arguments):<br><span style="color:blue;font-weight:bold;font-family:courier;">./break-2.bash hwd101 ipc144 uli101 apc100</span><br><br>What do you notice? How come '''uli101''' and '''apc100''' are NOT displayed<br>but a message appeared at the end of the script that the script completed?<br><br>
# Issue the following to run a checking script:<br><span style="color:blue;font-weight:bold;font-family:courier;">bash /home/murray.saul/myscripts~uli101/week12-check-3</span><br><br>
# If you encounter errors, make corrections and '''re-run''' the checking script until you<br>receive a congratulations message, then you can proceed.<br><br><br>
13,420
edits

Navigation menu