1

00:00:02,360  -->  00:00:06,629
All right! Welcome to this exercise
walkthrough. You know the drill: What

2

00:00:06,629  -->  00:00:09,809
we're going to do is look at our
requirements, and then we're going to go

3

00:00:09,809  -->  00:00:14,250
ahead and build a script to satisfy
those requirements. So the requirements

4

00:00:14,250  -->  00:00:19,380
for this particular scripting exercise
are that the script is named run-

5

00:00:19,380  -->  00:00:25,199
everywhere.sh, and what it does is,
it executes all arguments as a single

6

00:00:25,199  -->  00:00:34,920
command on every server listed in the
file, and by default that file is /vagrant/servers. This script also executes

7

00:00:34,920  -->  00:00:39,809
the provided command as the user executing
the script. So, we don't want people to

8

00:00:39,809  -->  00:00:44,219
execute this as sudo, we want them to
execute it as themselves, and that

9

00:00:44,219  -->  00:00:48,690
way they can have their own SSH key
set up and that sort of thing and do it

10

00:00:48,690  -->  00:00:52,649
that way, and if they want to use root
privileges, we'll provide them a way to

11

00:00:52,649  -->  00:00:57,539
do that that we'll talk about in just a
second here. So, another thing we want to

12

00:00:57,539  -->  00:01:04,049
do is use an SSH command that actually
times out in a relatively short period

13

00:01:04,049  -->  00:01:09,479
of time. We may have not really talked
about this in one of our demonstrations

14

00:01:09,479  -->  00:01:14,070
or one of our exercises before this, but
what can happen is, if you have a server

15

00:01:14,070  -->  00:01:18,780
that's down on the network and you try
to SSH to it, SSH can take a minute or

16

00:01:18,780  -->  00:01:23,549
two before it times out, and of course
any of these network commands such as

17

00:01:23,549  -->  00:01:29,549
ping or SSH or other similar commands
often have a way to control the timeout.

18

00:01:29,549  -->  00:01:35,759
So here, the way to do it with SSH is to
use the "-o ConnectTimeout=" and

19

00:01:35,759  -->  00:01:40,560
then some value. We'll use that option, and
so I've just decided to use two seconds.

20

00:01:40,560  -->  00:01:45,390
You could leave this out and let it fail
on its own, or you could use a longer

21

00:01:45,390  -->  00:01:49,200
duration if you want longer than two, but
I think this is good for our particular

22

00:01:49,200  -->  00:01:53,970
purposes. We also decided that this
script is going to allow the user to

23

00:01:53,970  -->  00:01:58,170
specify some options. The first option
that we're concerned with this -f and

24

00:01:58,170  -->  00:02:02,700
then a path to a file, and what this does
is allows the user to override the

25

00:02:02,700  -->  00:02:07,350
default file of /vagrant/servers. This way they can create

26

00:02:07,350  -->  00:02:11,470
their own list, or even sub list, of
servers, and execute commands against that

27

00:02:11,470  -->  00:02:16,750
list that they provide to to the script
so it's not hard coded, if you will.

28

00:02:16,750  -->  00:02:21,760
The next option is -n, which stands for
"dry run", and this allows for commands to

29

00:02:21,760  -->  00:02:27,010
be displayed instead of executed. And
another option we're going to give the

30

00:02:27,010  -->  00:02:32,320
user the ability to use is -s, which
runs the command with sudo or superuser

31

00:02:32,320  -->  00:02:37,030
privileges on the remote server. For
example, if they need to run a system

32

00:02:37,030  -->  00:02:40,920
administration command that requires
root privileges, they'll just use -s,

33

00:02:40,920  -->  00:02:46,840
they will be connected via SSH via their
normal user, and then sudo will be

34

00:02:46,840  -->  00:02:51,700
prepended to their command, which allows
it to be executed as root on the remote

35

00:02:51,700  -->  00:02:55,180
system. And of course, with sudo it has
to be configured, number one, and then,

36

00:02:55,180  -->  00:02:59,950
number two, there is a log file that
tracks who is running what commands with

37

00:02:59,950  -->  00:03:04,930
sudo. So that is a very good feature
indeed. Okay, so the last option we're going

38

00:03:04,930  -->  00:03:08,980
to allow for is -v, which enables a
verbose mode, and that just simply

39

00:03:08,980  -->  00:03:12,340
displays the name of the server for
which the command is being executed on.

40

00:03:12,340  -->  00:03:17,170
So, as you know, some commands generate output, and if you want to see what

41

00:03:17,170  -->  00:03:21,580
output is coming from what server, then
use -v, and then it will show you. So

42

00:03:21,580  -->  00:03:26,380
that's the whole idea behind that. Again,
we mention this, that we're going to

43

00:03:26,380  -->  00:03:31,180
enforce that the script be executed
without super user privileges, and if

44

00:03:31,180  -->  00:03:34,930
they do execute it with super user
privileges, let's just tell them to use

45

00:03:34,930  -->  00:03:38,920
the -s option, maybe give them a
usage statement, and then exit the script.

46

00:03:38,920  -->  00:03:43,180
Speaking of the usage statement, we're
going to create one. Much like you would

47

00:03:43,180  -->  00:03:47,650
see in a man page for a normal command
on a Linux system, we're going to create

48

00:03:47,650  -->  00:03:52,959
our own little mini man page. if you will.
for this script. If, for any reason, a

49

00:03:52,959  -->  00:03:57,489
command was not able to be executed
successfully on a remote host, we want to

50

00:03:57,489  -->  00:04:02,890
let the user know about that. And also, we
want to exit with a zero exit status if

51

00:04:02,890  -->  00:04:07,630
everything went okay, or, if everything
didn't go okay, we'll just exit with the

52

00:04:07,630  -->  00:04:13,390
most recent nonzero exit status from
the SSH command. And that could mean that

53

00:04:13,390  -->  00:04:17,470
we didn't connect to a host, or that
could mean that the command itself

54

00:04:17,470  -->  00:04:23,470
failed. The first step for this project
is to actually create a small internal

55

00:04:23,470  -->  00:04:26,890
network, if you will, of
three virtual machines. We're going to

56

00:04:26,890  -->  00:04:31,630
create an administration server, and then
two other servers that are going to act

57

00:04:31,630  -->  00:04:36,880
as the workhorses, if you will, for our
little network here. So, obviously the

58

00:04:36,880  -->  00:04:40,810
first thing you do is open up a command
line session on your local machine. We'll

59

00:04:40,810  -->  00:04:46,600
go into the shell class folder, and we're
going to create a "multinet" vagrant

60

00:04:46,600  -->  00:04:49,840
project. So that's what we're going to
name it - nothing special about the name,

61

00:04:49,840  -->  00:04:54,340
it's just something I chose - and then
what we're going to do is initialize our

62

00:04:54,340  -->  00:05:02,400
vagrant project, here, and we're going to
use the class image. Now, we need to edit

63

00:05:02,410  -->  00:05:07,900
our vagrant file to specify the three
machines that we want to have created by

64

00:05:07,900  -->  00:05:14,770
vagrant. So I'm just going to come down
here below the config,vm,box line, and

65

00:05:14,770  -->  00:05:28,000
add my configuration. So we'll create the
admin01 server first, here.

66

00:05:28,000  -->  00:05:38,500
I'll set the hostname to admin01,

67

00:05:38,500  -->  00:05:45,200
give it an
IP address of 10.9.8.10.

68

00:05:45,200  -->  00:05:49,330
and then I'm just going to copy this
configuration to the next one here.

69

00:05:49,330  -->  00:05:55,650
And so anywhere I see admin01, I'm just
going to change that to server01, and

70

00:05:55,650  -->  00:06:02,260
then the IP address is going to be .11 - very similar process here -

71

00:06:02,260  -->  00:06:10,240
or server02, so anywhere I see 01 just
change it to 02 - well, almost anywhere

72

00:06:10,240  -->  00:06:15,400
I see 01. Okay, so let me double check my
work here. I have admin01 with an IP

73

00:06:15,400  -->  00:06:21,700
address of 10.9.8.10, server01
10.9.8.11, and server02 with

74

00:06:21,700  -->  00:06:27,820
10.9.8.12. Okay, this looks
good. So now what we need to do is run

75

00:06:27,820  -->  00:06:31,510
"vagrant up" and it will create all three
of these systems, and then once it's up

76

00:06:31,510  -->  00:06:37,530
we'll connect to the admin01 server
and start writing our script.

77

00:07:06,730  -->  00:07:11,940
Okay, this looks good. Let me run
"vagrant status" to confirm.

78

00:07:11,940  -->  00:07:16,750
Sure enough, admin01, server01,
and server02 are all in the

79

00:07:16,750  -->  00:07:20,920
"running" state according to vagrant. And
now what we're going to do is connect to

80

00:07:20,920  -->  00:07:27,200
the admin01 system and do our work
from there. So I'll run "vagrant ssh admin01".

81

00:07:27,200  -->  00:07:32,370
Once here, I'm going to move into the
shared folder of /vagrant,

82

00:07:32,370  -->  00:07:43,000
and now i'm going to start editing our
script. So we're going to name it run-everywhere.sh.

83

00:07:43,000  -->  00:07:45,700
By default, we're going to
have a list of servers located at

84

00:07:45,700  -->  00:07:50,710
/vagrant/servers, and I'm
just going to put that variable at the

85

00:07:50,710  -->  00:08:02,470
very top of the script here. I'm going to
call it SERVER_LIST. Another variable I'm

86

00:08:02,470  -->  00:08:06,760
going to define at the top of our shell
script here is going to be around the

87

00:08:06,760  -->  00:08:11,260
SSH options that we're going to use for
our timeout settings. Now, this may be

88

00:08:11,260  -->  00:08:15,070
something, personally, that I would adjust
over time depending on how my network

89

00:08:15,070  -->  00:08:19,300
works and things like that. Maybe I'll
have other options that I think that

90

00:08:19,300  -->  00:08:22,480
I'll need to use in the future, so I'm
going to put these types of things at

91

00:08:22,480  -->  00:08:26,820
the very top of my script, here. So we'll
just, say...

92

00:08:36,100  -->  00:08:44,200
Unlike some of our other scripts, we do not want this script run with super user privileges.

93

00:08:44,200  -->  00:08:48,330
So, what we're going to do is do a check, like this.

94

00:09:12,749  -->  00:09:17,769
So, this says, if the UID is equal to zero,
that means we know they're executing

95

00:09:17,769  -->  00:09:20,860
this with root privileges, and
then we're going to tell them not to do

96

00:09:20,860  -->  00:09:25,179
that, and then use this -s option
that we're going to allow them to use

97

00:09:25,179  -->  00:09:30,550
instead. And -s, in my mind, stands
for sudo, or superuser. We're also

98

00:09:30,550  -->  00:09:34,179
going to give them a usage statement
here, and I'm just going to build that

99

00:09:34,179  -->  00:09:37,600
into a function because I know we're
going to need this later anyway, when

100

00:09:37,600  -->  00:09:44,800
we're doing things like parsing options.
So I'm going to put our usage function here.

101

00:09:52,600  -->  00:09:57,670
We're going to allow for the n, s, and v options.
We're also

102

00:09:57,670  -->  00:10:02,200
going to allow for a -f option, but that
requires a file if they use that, and

103

00:10:02,200  -->  00:10:06,900
then we are going to require a command.

104

00:10:16,200  -->  00:10:20,980
By the way, anything they provide on the
command line after the options is going

105

00:10:20,980  -->  00:10:25,030
to be treated as a single command. We're
just going to pass that over to ssh and

106

00:10:25,030  -->  00:10:28,930
allow that to be executed. So we're not
going to do anything super fancy here.

107

00:10:28,930  -->  00:10:33,370
This is going to allow us to do what we
need to do, and if the user wants multiple

108

00:10:33,370  -->  00:10:37,720
commands to be run on the remote host,
then they just need to enclose that in

109

00:10:37,720  -->  00:10:43,840
quotation marks so that entire command
gets sent over, and not changed by any

110

00:10:43,840  -->  00:10:48,820
shell expansion or anything like that. So,
we'll get to some of these examples in a

111

00:10:48,820  -->  00:10:51,250
minute, but I just wanted to point that
out really quick - that we're not

112

00:10:51,250  -->  00:10:56,650
promising the user anything other than
executing one command on every remote

113

00:10:56,650  -->  00:10:59,160
system.

114

00:11:49,379  -->  00:11:55,000
Oops, I see a typing mistake here, fix that.

115

00:12:06,900  -->  00:12:10,300
Okay, let's continue here. So, we're going to

116

00:12:10,300  -->  00:12:13,180
have them execute the script, then we're
going to make sure that they're not

117

00:12:13,180  -->  00:12:18,220
executing it with root privileges, and if
they make it past that check, well, then

118

00:12:18,220  -->  00:12:22,060
we can start parsing the arguments or
parsing the options.

119

00:12:26,800  -->  00:12:34,410
-f requires an argument, so we're going to put a : after that option, and the n, s, and

120

00:12:34,410  -->  00:12:36,774
v options do not.

121

00:12:40,900  -->  00:12:46,700
So, for the f option we're going to allow them to override the server list.

122

00:12:51,200  -->  00:12:55,320
The -n option
is just going to be dry run, and we'll

123

00:12:55,320  -->  00:13:01,860
just set that variable to true, and then
we'll check it later on in our script.

124

00:13:01,860  -->  00:13:06,269
S is for sudo and we'll set that to "sudo" and you'll see why I do that here in just a

125

00:13:06,269  -->  00:13:09,180
minute.
And then we're going to allow for

126

00:13:09,180  -->  00:13:14,459
VERBOSE, and we'll set that to true, and
then we'll check that later on. And any

127

00:13:14,459  -->  00:13:18,779
other option is going to be invalid, and
so we're going to teach them how to use

128

00:13:18,779  -->  00:13:23,300
the script with a usage statement here.

129

00:13:26,269  -->  00:13:31,829
So now that anything that's left on the
command line after we parse the options

130

00:13:31,829  -->  00:13:37,790
should be a command, so let's shift
everything over after the options.

131

00:14:10,470  -->  00:14:14,700
So the whole point of this script is for
a user to give us a command, and then

132

00:14:14,700  -->  00:14:18,300
this script will execute that command on
all the systems in the server list, and

133

00:14:18,300  -->  00:14:22,530
if they don't supply an argument after
options, well, then there are no commands

134

00:14:22,530  -->  00:14:26,700
to execute, so we should really tell them
how to use the script and exit. So, if

135

00:14:26,700  -->  00:14:32,730
there are no commands to execute, give
them "usage", and then exit. At this point,

136

00:14:32,730  -->  00:14:36,700
anything that remains is the command.

137

00:14:48,700  -->  00:14:51,060
So, now that we've checked that they're

138

00:14:51,060  -->  00:14:55,500
executing the script with non superuser
privileges, and that they actually gave

139

00:14:55,500  -->  00:14:59,340
us a command to execute over a list of
servers, now what we need to do is make

140

00:14:59,340  -->  00:15:03,510
sure that that list of servers actually
exists. And, remember, we allowed them to

141

00:15:03,510  -->  00:15:07,950
change that with a -f option above,
and that means they can give us any kind

142

00:15:07,950  -->  00:15:11,580
of data that they want. So, we need to
make sure that they gave us a path to a

143

00:15:11,580  -->  00:15:18,000
file and that we can read that file. So
we'll do a check right here.

144

00:15:44,000  -->  00:15:50,700
The if statement reads, if "! -e" (not exist) $SERVER_LIST, then we'll do these two commands here:

145

00:15:50,700  -->  00:15:55,650
echo "Cannot open server list", and tell them what file we tried to open. And what we're

146

00:15:55,650  -->  00:15:59,880
going to do is send that message to
standard error. And we do that, of course,

147

00:15:59,880  -->  00:16:04,860
with a &gt;&amp;2 and then we exit our script with a nonzero

148

00:16:04,860  -->  00:16:10,890
exit status. Speaking of exit statuses,
you know that one of our requirements is

149

00:16:10,890  -->  00:16:14,610
to make sure the script does not exit
with zero if there was an error somewhere

150

00:16:14,610  -->  00:16:20,010
along the way. So, one way we can
accomplish this goal is to set an exit

151

00:16:20,010  -->  00:16:23,699
status of zero at the beginning, and then
check

152

00:16:23,699  -->  00:16:28,739
for any nonzero exit statuses from the
ssh command as we execute them, and then

153

00:16:28,739  -->  00:16:33,239
if there happens to be a nonzero exit
status, then overwrite our default exit

154

00:16:33,239  -->  00:16:37,589
status for the script and then exit with
that exit status. So, what we're going to

155

00:16:37,589  -->  00:16:44,189
do here is just say to expect the best,
but we're going to prepare for the worst.

156

00:16:44,189  -->  00:16:50,879
And we do that with an exit status of
zero - we'll assume zero and

157

00:16:50,879  -->  00:16:54,000
then otherwise, we'll overwrite it.

158

00:16:54,000  -->  00:16:58,700
Okay, so now what we need to do is loop through the server list.

159

00:17:14,060  -->  00:17:18,209
So, what this for loop does
is it takes the contents of the server list

160

00:17:18,209  -->  00:17:23,700
file and assigns it to the variable
SERVER. So, the first item in SERVER_LIST

161

00:17:23,700  -->  00:17:27,539
will be assigned to SERVER, and
we'll go through this loop, and then the

162

00:17:27,539  -->  00:17:31,769
second line, or the second server, will be
assigned to SERVER and we'll do

163

00:17:31,769  -->  00:17:37,049
that until there are no more servers in this
server list. Now, we promised that if they

164

00:17:37,049  -->  00:17:40,590
were going to be in verbose mode, that we
were going to tell them what server

165

00:17:40,590  -->  00:17:44,429
we're about to execute a command on
before we do it. So, let's just put

166

00:17:44,429  -->  00:17:46,600
a quick check in here.

167

00:17:57,200  -->  00:18:00,600
Simple enough. And then, what we're going to do is actually

168

00:18:00,600  -->  00:18:06,000
build an ssh command with the ssh
command itself, the options that we

169

00:18:06,000  -->  00:18:08,909
specified at the beginning of the
scripts, the server that we're going to

170

00:18:08,909  -->  00:18:12,330
be executing the command on, and if we
need to execute it with sudo privileges,

171

00:18:12,330  -->  00:18:17,190
and then, of course, the command itself. So, the reason why I'm going to put this

172

00:18:17,190  -->  00:18:21,600
into a variable is that we're going to
need to use this variable twice. If it's

173

00:18:21,600  -->  00:18:25,919
a dry run we're just going to print this
variable, but if it's not, then we're

174

00:18:25,919  -->  00:18:29,429
actually going to execute it. So, in
theory, I could have written this out

175

00:18:29,429  -->  00:18:33,510
twice, but in kind of the spirit of not
repeating myself, I'm just going to

176

00:18:33,510  -->  00:18:37,290
create a variable to store this command
that we can use in

177

00:18:37,290  -->  00:18:40,740
two different ways, as you'll see here in
just a second. So, I'm going to store this

178

00:18:40,740  -->  00:18:44,680
command in the SSH_COMMAND
variable.

179

00:18:48,100  -->  00:18:51,400
So, the SSH_OPTIONS variable contains

180

00:18:51,400  -->  00:18:55,380
that "-o ConnectTimeout=" setting, and we're going

181

00:18:55,380  -->  00:18:58,700
to connect to a server that comes from the
server list, which is assigned to

182

00:18:58,700  -->  00:19:02,940
$SERVER in the for loop, then we're
going to execute the remote command with

183

00:19:02,940  -->  00:19:09,600
sudo if they provided the -s option. So,
if you remember, above, if they provided

184

00:19:09,600  -->  00:19:16,260
-s, we set $SUDO equal to "sudo" - the word
"sudo". Now, if they didn't supply the -s

185

00:19:16,260  -->  00:19:21,810
option, then the variable SUDO is not
set and it will just return an empty

186

00:19:21,810  -->  00:19:26,490
string, so it will not run with sudo
privileges, and we'll show this in a few

187

00:19:26,490  -->  00:19:29,820
minutes here. There are a couple of
different ways to handle that, that is

188

00:19:29,820  -->  00:19:34,080
one way. You could have also put a check,
you could have had SUDO set to "true"

189

00:19:34,080  -->  00:19:38,600
and then later on down here check: Oh, is
SUDO true? And then if so, then

190

00:19:38,600  -->  00:19:43,170
accommodate it there. Or, you can do it
like I've done it here. Again, as long as

191

00:19:43,170  -->  00:19:46,890
the script works, I don't really care how
you get there, as long as it makes sense

192

00:19:46,890  -->  00:19:50,970
to you, and it's actually functional. Okay,
so, obviously, the last thing left to do

193

00:19:50,970  -->  00:19:57,300
here is run the command. If it's a dry
run, we're not going to execute anything.

194

00:19:57,300  -->  00:20:01,860
We're just going to display what we
would have executed. So, let's put a check

195

00:20:01,860  -->  00:20:04,430
in right here.

196

00:20:24,170  -->  00:20:29,450
So, here, if it's a dry run, we just
display the words "DRYRUN" and then the

197

00:20:29,450  -->  00:20:33,290
command that we would have executed.
Otherwise, we're just going to execute

198

00:20:33,290  -->  00:20:35,400
this command.

199

00:20:39,400  -->  00:20:43,010
We're going to store the
exit status because we're going to check

200

00:20:43,010  -->  00:20:45,200
it, here, in a minute.

201

00:21:40,200  -->  00:21:43,850
Let's talk through
this last little bit of code, here.  So, we

202

00:21:43,850  -->  00:21:49,500
execute the ssh command, we store the
return code or exit value into the

203

00:21:49,500  -->  00:21:54,170
SSH_EXIT_STATUS variable, then we check that variable.

204

00:21:54,170  -->  00:21:58,610
If it's anything other than zero, then what
we're going to do is set the exit

205

00:21:58,610  -->  00:22:03,950
status of our program to that - that SSH_EXIT_STATUS variable. So, this

206

00:22:03,950  -->  00:22:08,360
allows that default value of zero to be
overridden if anything goes wrong along

207

00:22:08,360  -->  00:22:12,680
the way. Then we tell the user that the
execution failed, and we tell them on

208

00:22:12,680  -->  00:22:16,340
what server it failed, and, again, we're
sending that to standard error because

209

00:22:16,340  -->  00:22:21,320
it is an error message. Here, I chose not
to exit right after an error, and

210

00:22:21,320  -->  00:22:25,760
the reason for that is, let's say you have a
long list of servers - let's say 100

211

00:22:25,760  -->  00:22:30,320
servers - and on server number three, you
get an error. Well, you may want to

212

00:22:30,320  -->  00:22:34,820
continue executing that command on all
the servers that are up, or available, or

213

00:22:34,820  -->  00:22:37,550
whatever, without immediately exiting
because

214

00:22:37,550  -->  00:22:40,550
perhaps you just want to know the ones
that failed so you can look at them

215

00:22:40,550  -->  00:22:43,430
manually later instead of having to
figure out, okay,

216

00:22:43,430  -->  00:22:47,330
the command got executed on these two
servers, but not these other ones, so now

217

00:22:47,330  -->  00:22:50,900
I have to fix server number 3, or take it
out of the lists, or create a

218

00:22:50,900  -->  00:22:53,990
new list that doesn't contain the first
two that the command got ran on, and so

219

00:22:53,990  -->  00:22:58,100
on. So that was my thinking on not
exiting the script there. Of course, if

220

00:22:58,100  -->  00:23:01,790
you want to allow the user an option,
perhaps you can use a -e option

221

00:23:01,790  -->  00:23:05,600
that says, hey, exit on error, and then you
could check for that option here and

222

00:23:05,600  -->  00:23:10,550
then exit if the user set that, for
example. So, again, I love scripting, you

223

00:23:10,550  -->  00:23:14,900
can make these scripts do anything you
want. So, now that I have my script

224

00:23:14,900  -->  00:23:17,960
written, what I'm going to do is actually go
to the very top of the script and just

225

00:23:17,960  -->  00:23:22,310
kind of scan down it and look for some
common issues and common mistakes that

226

00:23:22,310  -->  00:23:27,920
everyone makes. For example, not
providing a matching quote, missing an

227

00:23:27,920  -->  00:23:33,470
opening or closing bracket, spelling of a
word, any of those types of errors, and I

228

00:23:33,470  -->  00:23:37,700
may not find them all right away, and if
not, that's okay. When I execute my script

229

00:23:37,700  -->  00:23:40,520
I'll see an error and then I can go back
and fix it because, again, I'm working

230

00:23:40,520  -->  00:23:44,270
here on a virtual machine on a test
system, and it's okay if I break things

231

00:23:44,270  -->  00:23:47,600
here, right? I'm not doing it on a
production server, and this is not going

232

00:23:47,600  -->  00:23:51,950
to wake anyone up in the middle of the
night and break anything super important.

233

00:23:51,950  -->  00:23:55,310
So, let me just jump to the very top of
the script and just start working my way

234

00:23:55,310  -->  00:24:00,000
down and see if I find anything that
looks obviously wrong to me.

235

00:24:01,800  -->  00:24:05,960
So, here, as I'm working my way down, I'm looking to make sure I don't have spaces in between

236

00:24:05,960  -->  00:24:09,740
the equal signs when I'm doing variable
assignments. I'm making sure that if I

237

00:24:09,740  -->  00:24:14,270
have a single quote at the beginning
that it ends with a single quote and not

238

00:24:14,270  -->  00:24:17,600
a double quote - I have done that in the
past, it's a common mistake to make

239

00:24:17,600  -->  00:24:22,370
mismatched quotes. If I'm using a bracket
I'm going to look to see if have an

240

00:24:22,370  -->  00:24:28,700
opening bracket and a closing bracket. If
I'm referencing a variable inside

241

00:24:28,700  -->  00:24:32,180
a statement, I'm going to make sure that
that statement is in quotation marks

242

00:24:32,180  -->  00:24:37,000
like this, double quotes so it gets
expanded - here I have it in double quotes,

243

00:24:37,000  -->  00:24:44,559
so that looks good. I'm just going to
keep going down, here. I don't see anything

244

00:24:44,559  -->  00:24:46,600
on that screen.

245

00:24:51,700  -->  00:24:57,220
Okay, here is an error. I actually need this dollar sign to be

246

00:24:57,220  -->  00:25:02,740
before the variable, and I actually need
a closing quotation mark, so if I had

247

00:25:02,740  -->  00:25:08,110
executed my script, I would have ran into
this bug. And I see a very similar thing

248

00:25:08,110  -->  00:25:13,340
right here that I did as well - I left off
a closing quotation mark.

249

00:25:21,400  -->  00:25:23,000
Same thing here.

250

00:25:23,190  -->  00:25:28,779
Okay, so today, I was not paying very close
attention to my closing quotation marks

251

00:25:28,779  -->  00:25:32,499
so I'm really glad I had taken the extra
minute here to look over my script.

252

00:25:32,499  -->  00:25:35,889
No promises that I'm not going to have
an error in a second, but if I do, we'll

253

00:25:35,889  -->  00:25:39,909
just troubleshoot it and figure it out
at that time. So, I'm just going ahead and

254

00:25:39,909  -->  00:25:42,389
save my changes.
