1
00:00:03,410 --> 00:00:05,420
Welcome to the exercise walk through.

2
00:00:05,420 --> 00:00:11,750
This is where you'll get a chance to look over my shoulder if you will and see how I approach this particular

3
00:00:11,750 --> 00:00:13,270
exercise.

4
00:00:13,280 --> 00:00:18,830
The first thing I want to do however is just set the stage give me a little bit of background information

5
00:00:18,920 --> 00:00:22,380
about a situation where you might use this in the real world.

6
00:00:22,580 --> 00:00:27,330
Let's say that you're a Linux system administrator for growing fast paced company.

7
00:00:27,410 --> 00:00:32,570
You have a lot of projects and deadlines that you're working on and working toward But you keep getting

8
00:00:32,630 --> 00:00:36,440
interrupted by the help desk to create new user accounts.

9
00:00:36,440 --> 00:00:40,470
You decide that your only hope for getting a couple of hours uninterrupted.

10
00:00:40,490 --> 00:00:45,230
That would give you some time to work on these projects and meet your deadlines is to actually automate

11
00:00:45,290 --> 00:00:49,210
and offload this account creation process to some other group.

12
00:00:49,460 --> 00:00:51,990
So you decide to go ahead and create a shell script.

13
00:00:52,010 --> 00:00:57,500
Test it on your local system and then upload that shellscript to where it can be used by staff of the

14
00:00:57,500 --> 00:01:02,180
helpdesk for example and that way they don't have to call you an email and interrupt you and you can

15
00:01:02,180 --> 00:01:04,820
focus on more high level work.

16
00:01:05,060 --> 00:01:09,290
So once you've decided that you're going to write this script you sit down and think about what should

17
00:01:09,290 --> 00:01:12,470
be in the script what it's got to do how it should work.

18
00:01:12,590 --> 00:01:17,210
If there are any checks you need to perform and so on and so you just scribble down a little list and

19
00:01:17,220 --> 00:01:19,020
here's what you've come up with.

20
00:01:19,070 --> 00:01:23,180
You decided to name the skip and local user dot sh.

21
00:01:23,360 --> 00:01:29,030
You also decide that you want to make sure that whoever is executing the script does so with root or

22
00:01:29,030 --> 00:01:33,220
super user privileges so that the account creation process can work.

23
00:01:33,290 --> 00:01:38,120
And if they don't do that if they don't run it as route or run it with sudo for example then you want

24
00:01:38,120 --> 00:01:43,820
to make sure to quit the script and exit out and you also want to follow standard command conventions

25
00:01:43,820 --> 00:01:48,560
and shellscript conventions by exiting with a non zero exit status.

26
00:01:48,680 --> 00:01:53,840
If the script doesn't fully complete properly so then you think about the next scenario where they actually

27
00:01:53,840 --> 00:01:56,600
do execute the script with the proper privileges.

28
00:01:56,780 --> 00:02:02,450
What information do you need from the person that is running the script in order to create an account.

29
00:02:02,480 --> 00:02:05,070
And of course you need at least a user name.

30
00:02:05,090 --> 00:02:09,590
You'll also want the full name of the person that will be using the account or who they helpdesk is

31
00:02:09,590 --> 00:02:10,980
creating the account for.

32
00:02:11,150 --> 00:02:16,830
And then you'll probably want to request an initial password so you can set that on the account.

33
00:02:17,120 --> 00:02:21,200
So the next thing that the script will do obviously is to take all that information and to create a

34
00:02:21,200 --> 00:02:22,750
local Linux account.

35
00:02:22,910 --> 00:02:27,740
From your experience as a Linux system administrator you know that from time to time the command that

36
00:02:27,740 --> 00:02:30,850
will add a user to a system will fail for various reasons.

37
00:02:31,040 --> 00:02:36,590
One reason might be that the person executing the command would supply a user name that is already in

38
00:02:36,590 --> 00:02:39,710
use and then they user add command will fail.

39
00:02:39,830 --> 00:02:44,780
So you want to account for those situations and you don't want to tell whoever's running the script

40
00:02:44,780 --> 00:02:48,420
that a user was created when in fact the user was not created.

41
00:02:48,440 --> 00:02:52,600
So you want to make sure that the user add command in your script executes properly.

42
00:02:52,610 --> 00:02:57,140
And if for some reason it doesn't you want to stop the execution of your script and just tell the person

43
00:02:57,140 --> 00:03:00,820
running the script that the account was not able to be created.

44
00:03:00,980 --> 00:03:05,360
Now at that time they will probably escalated to you or your team and you have to go in and figure out

45
00:03:05,360 --> 00:03:09,610
why it didn't execute properly and you don't expect the helpdesk staff to do that.

46
00:03:09,800 --> 00:03:14,660
But you want to make sure to not tell them that a user was created when in fact it wasn't.

47
00:03:14,660 --> 00:03:20,660
If on the other hand the user was created successfully you want to display the user name the password

48
00:03:20,690 --> 00:03:23,990
and the host where the account was created on.

49
00:03:23,990 --> 00:03:28,430
This way the person that's creating the account or running the script can take that information and

50
00:03:28,430 --> 00:03:32,140
deliver it to the end user who actually use the account that was created.

51
00:03:32,270 --> 00:03:37,640
So the user will know what their username is what their password is and on what system that that account

52
00:03:37,640 --> 00:03:38,870
exists on.

53
00:03:38,870 --> 00:03:44,600
By the way and the lessons leading up to this exercise we didn't explicitly cover how to determine the

54
00:03:44,600 --> 00:03:46,730
hostname of the machine that you're on.

55
00:03:46,730 --> 00:03:52,370
I've left that up to you so you can get used to referring to the bash man page and looking for the information

56
00:03:52,370 --> 00:03:53,330
that you need.

57
00:03:53,330 --> 00:03:54,880
Getting help and so on.

58
00:03:55,070 --> 00:04:00,850
You'll use the exact same concepts that we've used explicitly in the previous lessons for example how

59
00:04:00,860 --> 00:04:03,080
to look up a user ID and so forth.

60
00:04:03,080 --> 00:04:08,240
But I didn't give you the exact answer because again I wanted you to get that practice so you can do

61
00:04:08,240 --> 00:04:13,250
it on your own and this way if you ever encounter something that you're not 100 percent sure about you

62
00:04:13,250 --> 00:04:16,470
have the practice of going about how to find that information.

63
00:04:16,700 --> 00:04:19,820
So at this point you know that you're going to create a script you know what the scripts are going to

64
00:04:19,820 --> 00:04:21,190
do how it's going to work.

65
00:04:21,320 --> 00:04:26,210
And so now what you want to do is test it on your local machine before you turn it over and let other

66
00:04:26,210 --> 00:04:27,410
people use it.

67
00:04:27,410 --> 00:04:32,670
So the first thing you want to do is start a command prompt or terminal on your local machine.

68
00:04:33,070 --> 00:04:39,890
Then we're going to move into the class folder from here we're going to initialize a vagrant project

69
00:04:39,890 --> 00:04:41,500
called local users.

70
00:04:43,840 --> 00:04:47,470
If you've been following along in the earlier lessons you'll already have this folder.

71
00:04:47,480 --> 00:04:52,360
You don't have to do the make command but if that directory doesn't exist go ahead and create it.

72
00:04:52,360 --> 00:05:02,740
Now move into that folder and initialize your vagrant project.

73
00:05:02,850 --> 00:05:06,410
We want to give some indication of what machine we're logged into.

74
00:05:06,420 --> 00:05:11,790
So let's go ahead and set a hostname for this machine and we can do that by editing the vagrant file.

75
00:05:17,290 --> 00:05:21,570
Do that with the config that VM host hostname equals.

76
00:05:21,790 --> 00:05:28,040
And I'm going to set this to local users and then right and quit see my changes here.

77
00:05:28,100 --> 00:05:30,680
Now we're ready to bring up the VM and connect to it.

78
00:05:30,680 --> 00:05:33,060
So we're run vagrant up to start the VM

79
00:05:40,150 --> 00:05:40,450
OK.

80
00:05:40,460 --> 00:05:46,900
Now that the virtual machine is up let's connect to it with vagrant S-sh.

81
00:05:46,920 --> 00:05:52,410
So now let's move into the shared a vagrant folder which is mounted inside the virtual machine at slash

82
00:05:52,410 --> 00:05:53,580
vagrant.

83
00:05:53,580 --> 00:05:59,010
So here you have a choice either to develop and write your script inside the virtual machine or to develop

84
00:05:59,010 --> 00:06:04,320
and write your script on your local machine but save it into the shared folder.

85
00:06:04,380 --> 00:06:10,290
Again I'm a big fan of them so I'm just going to create the script right inside the virtual machine.

86
00:06:10,290 --> 00:06:14,920
We already know that you decided to name it add dash local Desch user not S.H..

87
00:06:15,060 --> 00:06:20,160
So we'll go ahead and use that filename.

88
00:06:20,390 --> 00:06:24,450
I'm sure you know by now that every single script we're going to write starts with the shebang.

89
00:06:25,880 --> 00:06:31,400
And then now we're going to put a header at this file to give anyone who looks at it an idea of what

90
00:06:31,400 --> 00:06:32,190
it does.

91
00:06:39,800 --> 00:06:45,200
So this group creates a user on the local system and we're going to tell them what we're going to ask

92
00:06:45,200 --> 00:06:45,980
them for.

93
00:06:52,470 --> 00:06:53,700
We're going to ask them for the username.

94
00:06:53,700 --> 00:07:00,630
It's also called the log in the person's name that would be used in the account and a password for that

95
00:07:00,630 --> 00:07:01,490
account.

96
00:07:01,860 --> 00:07:05,490
And finally the main thing that this script does is display that information.

97
00:07:13,060 --> 00:07:17,140
If you think back to the shellscript requirements that we came up with we wanted to make sure that the

98
00:07:17,140 --> 00:07:20,070
script was being executed with super user privileges.

99
00:07:20,170 --> 00:07:21,430
So let's check for that.

100
00:07:21,430 --> 00:07:25,620
First off there's no need to prompt them for a user name or password.

101
00:07:25,750 --> 00:07:30,380
If we're not going to be able to use it anyway so let's just do that right at the top of the script.

102
00:07:39,600 --> 00:07:40,760
We'll use an if statement

103
00:07:43,640 --> 00:07:50,830
we're going to check the you ID that is set by Bassets a shell variable that gets set anytime bashers

104
00:07:50,880 --> 00:07:51,640
started.

105
00:07:51,830 --> 00:07:57,100
And this variable you idea is read only so it can be changed so we can trust it.

106
00:07:57,110 --> 00:08:01,650
Another thing we know is that the root account always has a id of 0.

107
00:08:01,790 --> 00:08:04,470
So we can test against the idea of zero.

108
00:08:04,640 --> 00:08:12,080
So if the ID is not equal to zero which means they're not executing with super user privileges then

109
00:08:12,080 --> 00:08:18,060
what we want to do is give them a message.

110
00:08:18,280 --> 00:08:25,020
So we'll use this chance to teach them how to use the script and then we want to follow convention and

111
00:08:25,050 --> 00:08:27,630
exit with a non zero exit status.

112
00:08:27,750 --> 00:08:32,130
Since we're not doing anything specific with these exit statuses we'll just use one.

113
00:08:32,310 --> 00:08:37,420
Finish up our IF statement here and that is our check for super user privileges.

114
00:08:37,770 --> 00:08:42,360
Now if they have executed the script with the proper privileges now we need to start collecting some

115
00:08:42,360 --> 00:08:46,040
information and we know how to do that by using the read shell built in.

116
00:08:46,050 --> 00:08:47,630
So let's build that right now.

117
00:08:51,550 --> 00:08:57,960
We'll give them a prompt which dash P stands for prompt and we'll follow that with enter the user name

118
00:08:57,970 --> 00:08:59,320
to create.

119
00:08:59,470 --> 00:09:04,640
We're going to use a space so that when they start typing it's not mushed up against the colon there.

120
00:09:04,650 --> 00:09:09,970
We're going to assign what they type into a variable and we're going to call this variable user underscore

121
00:09:09,970 --> 00:09:11,200
name.

122
00:09:11,200 --> 00:09:17,070
Now by the way when you're writing this script you could have chosen any other name for your variable.

123
00:09:17,140 --> 00:09:24,250
You might have said log in here you might have said account name you might have named it dog or cat

124
00:09:24,280 --> 00:09:28,820
which doesn't make any sense but it's valid syntax so in theory that's OK.

125
00:09:28,930 --> 00:09:34,690
So before I go any further I do want to point out here that this is one way to implement this shellscript

126
00:09:34,690 --> 00:09:39,160
and there are multiple ways and that's one of the things that I love about Linux and shell scripting

127
00:09:39,160 --> 00:09:44,860
specifically is that there are multiple ways to do things and it allows for some creativity and individuality

128
00:09:45,190 --> 00:09:50,130
while still being able to do useful work and allowing other people to read your code.

129
00:09:50,380 --> 00:09:54,970
So just know if you use a different prompted if a variable name that is totally acceptable.

130
00:09:55,060 --> 00:10:00,160
The main thing is does your shellscript deliver on their requirements.

131
00:10:00,220 --> 00:10:04,530
For example this group does it exit when it's not executed with super user privileges.

132
00:10:04,600 --> 00:10:06,110
If it does then you did it right.

133
00:10:06,130 --> 00:10:08,940
And if it doesn't then you need to adjust your code.

134
00:10:09,150 --> 00:10:10,450
Ok enough aside.

135
00:10:10,450 --> 00:10:11,650
Let's keep going on here.

136
00:10:11,650 --> 00:10:16,120
So now we have the user name the next bit of information that we want to collect from the person running

137
00:10:16,120 --> 00:10:18,550
the script is their real name.

138
00:10:26,600 --> 00:10:33,320
And actually this is just going to be the contents for the description field or comment filled in the

139
00:10:33,320 --> 00:10:34,440
password file.

140
00:10:34,550 --> 00:10:39,410
So this may or may not actually be a real name for example if someone is creating an account for an

141
00:10:39,410 --> 00:10:42,340
application this might be the application name.

142
00:10:42,380 --> 00:10:46,270
So we're going to go ahead and account for that in our script because we're thinking of it now.

143
00:10:46,280 --> 00:10:50,260
Now if you just said real name or person name that's totally fine as well.

144
00:11:00,570 --> 00:11:04,100
We're going to call this comment.

145
00:11:04,310 --> 00:11:10,580
And now the last bit of information we need to get is the password.

146
00:11:10,800 --> 00:11:19,420
Again we'll use the read belt with a dash P to prompt the user.

147
00:11:19,830 --> 00:11:24,750
And we're going to assign this to the pass word variable.

148
00:11:24,750 --> 00:11:28,050
Now that we have all the information we need we can go ahead and create the account

149
00:11:31,990 --> 00:11:37,030
hey we'll use the user add command and the user add command requires root privileges.

150
00:11:37,030 --> 00:11:39,350
That's why we did the check at the beginning of the script.

151
00:11:39,550 --> 00:11:47,800
So what we want to do here is use the dash see option and supply the comment or the name or whatever

152
00:11:48,010 --> 00:11:49,550
that was given to us.

153
00:11:49,660 --> 00:11:57,130
And that is stored in that comment variable and we enclose that in quotes so that even if there will

154
00:11:57,130 --> 00:12:00,600
be spaces in this comment it's all treated as the comment.

155
00:12:00,600 --> 00:12:06,520
So Jane space Smith will all go into the comment field and it will not be interpreted as two different

156
00:12:06,520 --> 00:12:09,850
things Jane being one thing and Smith being another.

157
00:12:09,850 --> 00:12:14,410
Now we want to ensure the home directory gets created so we can use the dash him flag.

158
00:12:14,590 --> 00:12:19,870
And then finally we need to specify the account name the log in name or the user name as I like to call

159
00:12:19,870 --> 00:12:20,270
it.

160
00:12:20,440 --> 00:12:26,770
At the end of the user at command here so we talked about this earlier we want to make sure that this

161
00:12:26,770 --> 00:12:32,480
command succeeds and how we can do that is to check the exit status of the user and command.

162
00:12:32,560 --> 00:12:36,000
So let's write a brief comment about it and then implement that check.

163
00:12:43,920 --> 00:12:47,280
We don't want to tell the user that an account was created when it was a

164
00:12:54,700 --> 00:13:00,560
hey we'll start off our IF statement double brackets will make sure to use a space and then we know

165
00:13:00,590 --> 00:13:06,860
that the exit status of the most previously executed command is stored and dollar sign.

166
00:13:06,860 --> 00:13:07,850
Question mark.

167
00:13:08,090 --> 00:13:13,170
And so again as convention holds if it's an exit status of 0 That means everything.

168
00:13:13,190 --> 00:13:14,700
Well the command succeeded.

169
00:13:14,750 --> 00:13:17,750
And if it's not zero then something went wrong.

170
00:13:17,750 --> 00:13:23,180
So if the exit status is not equal to zero that's what the dash and he stands for.

171
00:13:23,180 --> 00:13:25,300
Then we're going to display an error message

172
00:13:31,160 --> 00:13:37,650
and then we're going to exit our script with a non-zero exit status.

173
00:13:37,660 --> 00:13:42,910
Now assuming that we get past the if statement in the script that means the user had command succeeded.

174
00:13:42,910 --> 00:13:45,380
Now what we want to do is set the password for the account

175
00:13:48,660 --> 00:13:50,750
we're going to echo the password.

176
00:13:53,210 --> 00:13:58,920
And then we're going to pipe that output as the input to the password command.

177
00:13:58,970 --> 00:14:03,520
SS W.D. with a dash dash s t d i n option.

178
00:14:03,800 --> 00:14:09,210
And we're going to supply the username if we want to be really safe.

179
00:14:09,210 --> 00:14:12,830
We can also check to see if the password command succeeded.

180
00:14:12,900 --> 00:14:18,060
And if the password was properly set on the account again if something goes wrong here then the account

181
00:14:18,060 --> 00:14:23,870
is not fully completed so will want to exit with a non-zero exit status.

182
00:14:23,880 --> 00:14:27,230
So again we'll check for dollar question mark.

183
00:14:27,570 --> 00:14:31,480
If it doesn't equal 0 then display an error message.

184
00:14:38,010 --> 00:14:42,760
And then exit with an exit status of 1 and finish our IF statement.

185
00:14:42,770 --> 00:14:47,510
Finally what we want to do is force the password change on first log in

186
00:14:51,820 --> 00:14:56,980
and we can do that with a password command with a dash option and give it the user name that we're operating

187
00:14:56,980 --> 00:14:59,020
against.

188
00:14:59,020 --> 00:15:03,790
So at this point you could even do another check to make sure that this execution of the password command

189
00:15:03,790 --> 00:15:04,650
succeeded.

190
00:15:04,720 --> 00:15:10,270
While I'm looking at my script here I notice that I did something that will probably work but is not

191
00:15:10,270 --> 00:15:13,380
a best practice back in my previous IF statement here.

192
00:15:13,540 --> 00:15:18,220
I forgot to enclose this variable in quotes and I want to make sure I do that.

193
00:15:18,220 --> 00:15:22,320
So let me go ahead and add that back in.

194
00:15:22,340 --> 00:15:25,070
So now we set our password.

195
00:15:25,070 --> 00:15:28,210
We force the password to be changed on first log in.

196
00:15:28,240 --> 00:15:33,650
And so now what we want to do is display this information to the person running the script so that they

197
00:15:33,650 --> 00:15:40,390
can then handed off to the user that will be using the account so we're going to give them the username

198
00:15:40,770 --> 00:15:46,210
and password and the host where the user was created.

199
00:15:46,210 --> 00:15:52,630
Now I know the password command generate some output and I want to separate this output from that output

200
00:15:52,640 --> 00:15:58,230
so I'm going to use the echo statement on its own without any options or without any arguments.

201
00:15:58,300 --> 00:16:02,540
The echo statement displays what is passed to it and a new line.

202
00:16:02,560 --> 00:16:06,560
So if you don't pass anything to echo it's ultimately going to print a blank line.

203
00:16:06,610 --> 00:16:09,220
And so that's what we'll use it for here.

204
00:16:09,340 --> 00:16:16,500
Now let's display the user name and will display this on the next line.

205
00:16:19,090 --> 00:16:24,010
Let's add a blank line and we'll tell them the password.

206
00:16:28,180 --> 00:16:32,870
And finally we want to tell them the host.

207
00:16:32,950 --> 00:16:38,050
So at this point if you don't know how to get the hostname what you can do is look at the bash man page

208
00:16:38,050 --> 00:16:42,860
and let's do that really quickly now see my changes type man bash.

209
00:16:43,100 --> 00:16:48,590
So let's perform a search and see if we can find anything about a host name and the bash man page and

210
00:16:48,620 --> 00:16:54,410
perform a search we'll use a forward slash which is a Ford search will type hostname and press enter

211
00:16:54,770 --> 00:16:58,230
and sure enough we come to something that is in all uppercase letters.

212
00:16:58,430 --> 00:17:03,650
And as we know by convention something in all uppercase letters can be a variable name.

213
00:17:03,800 --> 00:17:09,040
So this variable says that it's automatically set to the name of the current host.

214
00:17:09,170 --> 00:17:15,080
So if we scroll back up here we can make sure that this is indeed in the variable section and will keep

215
00:17:15,080 --> 00:17:16,150
going up here.

216
00:17:23,390 --> 00:17:26,450
And sure enough it's in the shell variables.

217
00:17:26,600 --> 00:17:29,350
So we can get queue to exit out of here.

218
00:17:29,480 --> 00:17:31,650
Let's look at the value of it.

219
00:17:34,070 --> 00:17:40,030
Get it set to local users which is the name of our system that we're currently on you can see our username

220
00:17:40,030 --> 00:17:42,650
vagrant at local users.

221
00:17:42,670 --> 00:17:46,770
So let's get back into our shellscript and and that last bit of information.

222
00:17:56,470 --> 00:18:00,890
So if we get to this point the script is really complete and it's completed successfully.

223
00:18:01,030 --> 00:18:06,420
So by convention we need to exit with a zero exit status so we can do that with this.

224
00:18:06,430 --> 00:18:12,290
Now let's save our script and start testing it the first time we execute this script.

225
00:18:12,290 --> 00:18:15,330
We want to make sure that it has executable permissions

226
00:18:18,970 --> 00:18:19,270
OK.

227
00:18:19,270 --> 00:18:27,150
Let's go ahead and add a user with a script that we created.

228
00:18:27,280 --> 00:18:37,990
Let's create a username of Einstein the real name will be Albert ein stion and the password will set

229
00:18:37,990 --> 00:18:45,370
to something like E equals MC squared theory and end it with a dollar sign.

230
00:18:45,520 --> 00:18:51,010
Hey we get some output from the password command and then we get the output that we displayed at the

231
00:18:51,010 --> 00:18:56,880
bottom here the user name the password and the host that it was created on.

232
00:18:56,890 --> 00:19:04,020
So it looks like the script function normally we can check the exit status with Echo dollar question

233
00:19:04,060 --> 00:19:05,540
mark.

234
00:19:05,570 --> 00:19:09,140
Sure enough we have a zero exit status so that all looks good.

235
00:19:09,960 --> 00:19:15,720
Now let's look at the ETSI password file to see if the user was created and used the cat ETSI password

236
00:19:15,720 --> 00:19:22,740
command or even the tail ETSI password command which will just print the bottom of the file so you can

237
00:19:22,740 --> 00:19:29,910
see it the last line of the file here is the Einstein user and that the comment is included in the account

238
00:19:29,910 --> 00:19:32,550
line and everything looks good there.

239
00:19:33,270 --> 00:19:37,320
To really test if the account was created properly let's go ahead and switch to that user.

240
00:19:37,470 --> 00:19:43,500
So I use su for switch user space and dash to get the users log in environment space.

241
00:19:43,500 --> 00:19:46,240
Einstein which is use name.

242
00:19:46,410 --> 00:19:49,560
Now it's prompting us for the password which we can enter now.

243
00:19:50,910 --> 00:19:56,310
Sure enough it accepted the password that we supplied when we executed our script and now it looks like

244
00:19:56,310 --> 00:20:00,600
it's forcing us to change the password which is exactly what we wanted to happen.

245
00:20:00,630 --> 00:20:03,730
So let's go ahead and retype in the current password.

246
00:20:04,800 --> 00:20:12,610
Now let's go ahead and give it a new password something like let's say crazy hair and end it with an

247
00:20:12,610 --> 00:20:13,700
exclamation point.

248
00:20:17,220 --> 00:20:17,500
OK.

249
00:20:17,510 --> 00:20:20,970
Now that we've proven that the script works for creating accounts.

250
00:20:21,080 --> 00:20:25,110
Let's see what happens when we execute the script without the proper privileges.

251
00:20:25,130 --> 00:20:27,970
So I'll just type and exit to get back to our vigor and account.

252
00:20:28,130 --> 00:20:34,790
So let's do this dot forward slash add local user dot SH sure enough it exits the script doesn't ask

253
00:20:34,790 --> 00:20:39,650
us for the account name or the password or any that doesn't attempt to create the account which is exactly

254
00:20:39,650 --> 00:20:41,300
what we want to happen.

255
00:20:41,300 --> 00:20:46,490
It gives us a status message here that teaches the user how to actually use the script which is really

256
00:20:46,490 --> 00:20:47,090
good.

257
00:20:47,090 --> 00:20:49,550
Now we want to check the exit status and see it here.

258
00:20:49,590 --> 00:20:53,640
Ecko dollar sign questionmark and press enter.

259
00:20:53,640 --> 00:20:56,580
Sure enough it's a non zero exit status.

260
00:20:56,610 --> 00:21:01,470
So our script fits all of our requirements and it works exactly as expected.

261
00:21:01,470 --> 00:21:06,330
Again I just want to say that if you didn't come up with the exact script that I did line by line that

262
00:21:06,330 --> 00:21:12,180
is ok as long as these tests pass because that means that your script works and that's all that really

263
00:21:12,180 --> 00:21:13,090
matters.

264
00:21:13,420 --> 00:21:15,490
Ok I hope you enjoyed writing this script.

265
00:21:15,490 --> 00:21:18,960
Now we're going to move on and learn some more about shell scripting.
