Changes

Jump to: navigation, search

Tutorial10: Shell Scripting - Part 1

6 bytes added, 17:26, 17 February 2021
INVESTIGATION 2: USING VARIABLES IN SHELL SCRIPTS
# Confirm that you are located in your '''home''' directory in your Matrix account.<br><br>
# Use a text editor to edit the shell script called '''hello'''<br><br>
# Add the following line to the bottom of the file:<br><span style="font-family:courier;">ps -o cmd= -p $$|cut -d" " -f1</span><br><br>'''NOTE: ''' This command displays the name of the shell that the shell script <br>is running within.<br><br>
# Save your editing changes and exit your text editor.<br><br>
# Issue the following linux command to change to run this shell script with the Bourne Shell (a different shell than the default Bashi.e. '''sh'''):<br><span style="color:blue;font-weight:bold;font-family:courier;">shhello</span><br><br>
# Issue the following linux command to confirm you are in the Bourne Shell:<br><span style="color:blue;font-weight:bold;font-family:courier;">echo $0</span><br><br>You should see the output of the command that you are located in shows '''sh''' (i.e. the '''Bourne Shell''').<br><br>
# While in the ''Bourne Shell'', run your shell script: <span style="color:blue;font-weight:bold;font-family:courier;">./hello</span><br><br>What shell does the shell script indicate is running?<br>You should notice that this script is being run in the Bourne shell.<br><br>Although your shell script should work, it is recommended to force your shell script to run in a '''specific''' shell.<br>This helps prevent your shell script encountering errors when run in the incorrect shell<br>(i.e. syntax not recognized in a specific shell).<br><br>
13,420
edits

Navigation menu