Changes

Jump to: navigation, search

OPS235 Lab 1 - CentOS7 - VMware

1,904 bytes added, 07:43, 22 May 2016
no edit summary
{{Admon/note|Bash Shell Reference Guide:|<br>'''<u>She-bang Line</u>'''<ul><li>Forces shell script to run in a specific Shell</li><li>Some shell syntax not backward compatible</li><li>'''#!''' must be at beginning of first line of shell script</li><li>Example: '''#!/bin/bash'''<br><br></li></ul>'''<u>Variables</u>'''<br><br>'''Environment'''<ul><li>System-wide or "global" variable (usually UPPERCASE)</li><li>Can view with command: '''set &#124; more'''</li><li>'''$''' in front to expand variable to value<li>Examples: '''USER''', '''PATH''', '''HOME''', '''SHELL'''<br><br></li></ul> '''User-defined''' <ul><li>Variable created by user (command line, scripting)</li><li>Examples:<br>''myVar&#61;"my value"; readonly myVar; export myVar''<br>''read -p "enter value: " myVar''<br><br></li></ul>'''Positional parameters'''<ul><li>Assign values with set command or shell script arguments</li><li>These variables are numbered (eg. $1, $2 ... $10}</li><li>Special parameters: $*, $@, $#, $$, $?<br><br></li></ul>''''''Command Substitution''''''<ul><li>Useful method to expand output from a command to be used as an argument for another command.</li><li>Examples:<br>''file $(ls)''<br>''set $(ls);echo $#;echo $*''<br>''echo "hostname: $(hostname)"''<br><br><li>'''Logic Control Flow Statements:'''<br><br>The '''test''' command can be used to see if a condition is true or false<br>(i.e. test $USER &#61; "root") . The '''$?''' special shell variable stores the result (zero if true, non-zero if false). Square brackets '''[ ]''' can be used to represent the test command with the condition <u>inside</u> the brackets (spaces separating brackets).Can use '''if''' / '''if-else''' / '''if-elif-else''' statements with brackets. The '''exit''' command can be used to terminate the shell script with a false value.<br><br>'''<u>Examples</u>'''<br><br>''if [ $USER &#61; "root" ]''<br>''then''<br>&nbsp;''echo "You must be root" >&amp;2''<br>&nbsp;''exit1''<br>''fi''<br><br># For number comparison: use:<br># -gt,-ge, -lt, -le, -eq, -ne<br><br>''if [ $age -gt 65 ]''<br>''then''<br>&nbsp;''echo "retire"''<br>''else''<br>&nbsp;''echo "don't retire"''<br>''fi''<br><br>''if [ $grade -gt 79 ]''<br>''then''<br>&nbsp;''echo "You get Good Mark"''<br>''elif [ $grade -gt 49 ]''<br>''then''<br>&nbsp;''echo "You pass"''<br>''else''<br>&nbsp;''echo "You fail"''<br>''fi''<br></li></ul>}}
|}
 
 
Explanation
 
<table cellspacing="0" cellpadding="5" width="50%" style="border-top: thin solid black;margin-left:20px;">
<tr valign="top>
 
<td style="border-bottom: thin solid black;font-weight:bold;background-color:#ffffff;">Button(s)</td>
<td style="border-bottom: thin solid black;font-weight:bold;background-color:#ffffff;">Purpose</td>
</tr>
<tr valign="top">
<td width="20%" style="border-bottom: thin solid black;">[[Image:t1.png|left|30px|]]</td>
<td width="20%" style="border-bottom: thin solid black;">'''Toggle''' between '''auto-hide''' and '''always show toolbar'''</td>
</tr>
<tr valign="top">
<td width="20%" style="border-bottom: thin solid black;">[[Image:t2.png|left|210px|]]</td>
<td width="20%" style="border-bottom: thin solid black;">'''Text-based menu''' for common operations</td>
</tr>
<tr valign="top">
<td width="20%" style="border-bottom: thin solid black;">[[Image:t3.png|left|110px|]]</td>
<td width="20%" style="border-bottom: thin solid black;">'''Common Guest VM Operations''' (Left to Right):'''Shutdown''', '''Suspend''', '''Start''', '''Restart'''</td>
</tr>
<tr valign="top">
<td width="20%" style="border-bottom: thin solid black;">[[Image:t4.png|left|100px|]]</td>
<td width="20%" style="border-bottom: thin solid black;">'''Snapshot (i.e. Restore Points)'''<br>(left to Right): Take '''new Snapshot''', Revert to '''Parent Snapshot''', '''Manage Snapshots'''</td>
</tr>
<tr valign="top">
<td width="20%" style="border-bottom: thin solid black;">[[Image:t5.png|left|30px|]]</td>
<td width="20%" style="border-bottom: thin solid black;">'''Exit Full Screen''' mode</td>
</tr>
<tr valign="top">
<td width="20%" style="border-bottom: thin solid black;">[[Image:t6.png|left|110px|]]</td>
<td width="20%" style="border-bottom: thin solid black;">'''Running''' Virtual Machines</td>
</tr>
</table>
 
 
'''Perform the Following Steps:'''
13,420
edits

Navigation menu