[Autogenerated] And yes,
we're diving out now so we can go through and take a
look at extending our said files.
Yes, we're going to be learning even more.
It's just not going to stop.
Is it?
We want to take a look at how we can branch inside of our said files.
So we can cater for those all important differences
that are always going to be there.
So this allows us to cater for those different settings and the
different conditions that we're going to come across.
We really want a very flexible file that is really going to work for us.
So come on, let's go through and take a look at this.
Now, this is what I like.
This is a learning environment.
They're not slides its your command line and a command line
where we can learn a little bit more about creating and
managing branching within our sd files.
Are you ready to go?
Let's begin by just checking the state of our sd and
AC and the SSH client alive sd.
Now, we could use this file,
but we're better off creating our own because if we create our own,
then we have the eyes and the muscle memory as we're
starting to write this and watch it.
It also gives me an idea of how to explain line by
line what we're actually writing.
But if you are struggling and you can't get it working,
this file is there for you to be able to use,
having verified that we do have a file we're going to create.
Now, our client dot Z, I'm just giving it a different name.
So we know which file we're working with.
Now we saw within the sample and the slides that we do have SSH shebang,
we don't need to put it,
but it becomes a good reminder as the purpose of this file.
So if I go through then and put in my she so being bin and said,
I can remind that we need to use an enhanced regular
expression and we need to reference this file,
we can go through and then start looking for our text.
We going to put in client a live interval.
We're not putting any meta characters saying the beginning or end of the line.
So this can appear anywhere in the line.
But because we might want to do different things with it,
having searched for this text,
we can put our brace brackets allowing us to run
blocks of code against this line,
we can work with a substitution that first off looks for client to
live interval being at the beginning of the line.
So we can go through and specify our client a live interval.
And I'm putting this inside of parentheses,
putting it inside of parentheses allows me to use it as a group.
This makes it easier when I put my replacement text in.
Now, after the client, a live interval, we can have dot Being any character,
an asterisk applying to that dot Saying any amount of those
characters before we get to the dollar, the end of line.
So dot Any character asterisk,
any amount of those characters and dollar being the end of the line,
that's the end of our search string and the start of our replacement text.
And we're going to begin this with back slash one with back slash one.
We're specifying the first group.
So we're then taking the client to live interval and pasting it into
that space and we're going to have 60 following it.
So any line that begins client to live interval is going to
have the value of 60 seconds following it.
Now, if this substitution is successful using the T for test,
we can go ahead and execute a label to go to.
If we use the upper case T rather than the lowercase T,
we'd be looking at a failed substitution and we're going to the label count.
The label is literally just a line in the file.
If we carry on past this, obviously, we failed on the first substitution.
The line didn't begin with client a live interval.
So we can actually now go through and substitute the complete
line dot and star with the setting that we want.
So that's going to be client a live interval space and 60.
So whether it's at the beginning of the line or commented further into our line,
we're going to make sure we've got the correct value.
And again, then we're going to on a successful substitution,
move to the count label,
we can close our block of code and there we have our
client a live interval catered for.
Now, to be honest,
we could probably get away with just running the second
substitution because that's going to work whether it was the
start of the line or end of the line.
But we want to show you how blocks of code can be executed.
And we want to be able to show you the idea of grouping.
But with that done,
we had better define our label count so we can add extra lines
for readability and we can add the label count.
So this is the target of our successful tests.
And the label literally is just this line,
but we will then continue from the label onwards.
So we can then go through and specify that we want to
perhaps let's copy these lines down.
So we can ____ these six lines and then paste them below here.
And then we can go through and change our client a live
interval to be client alive count.
And max let's throw this into my paste buffer.
So we can easily paste it down and Now, of course,
I can go through and delete these words and paste in the client alive.
Count max and move down, do the same thing here.
Or we can go through and delete the word client to live
interval and paste in from my buffer.
Don't forget to change the values.
So we can have three counts three cycles of my interval without my
client responding before we drop the client.
And of course, then we want to be moving to a different label.
Otherwise we've got ourselves in a bit of a loop.
So we're going to then go through and move to the label Dell.
And this is where we can then remove our commented lines,
leaving the commented lines in first means at least we can have
these two lines in the right place because they're in the file but
commented out as we then go through,
we can clean up the rest of our comments and empty
lines through our normal deletion, which we know by now.
So with this in place,
we can manage the two settings that we need and tidy up
our file all within the one set file.
If we go through and take a look at our SSH D underscore config,
we can see that it is an a standard state.
So highly commented.
If we look at them running against this,
we're not editing it at the moment,
but we can see then the upper case E and F going through to my client said,
and the SSH D configuration,
we can see now that we've got the client alive interval
being set to 60 and the count set to three.
Let's redirect this through to another file.
So its a simple test.
Now, we've got file one.
And if we go through and look at file one,
then again, we're seeing the same information that we saw from the screen.
But let's then check that it's working if we have the wrong value.
So we'll turn off our client a live interval set, our count to 10 run through.
Again, obviously,
we don't need to redirect and we need to look at our file
one with our new edited content and we can see then that
we're back to 60 and three.
So its working,
whether the line was commented or just had the wrong value and we're
now really starting to gain some power from this.
Now,
I hope you're really satisfied with yourself and happy to move on to
where we can start looking at editing remotely.