Do wild scripts do what scripts are very similar to for loop strip scripts.
The do wild script or statement continually executes a block of statements while a particular condition
is true or met.
For example, if you are running a script and you create it in a loop, it will run until a certain
variable is met.
For example, if you have if you wanted to run the script until August 2015 at 2:02 p.m., then you
will define that and do wild script.
And a lot of times the scripts are the daemons, the process that never dies, that keep running and
running and running.
They always have do wild scripts because they are running continuously until a certain condition is
met.
So for example, run a script until 2 p.m..
As soon as the 2 p.m. hits, you are done.
Exit out while condition do come and one command two, command three.
And once all these commands are done and the condition is done, then you are done.
You are done with your script.
So let's look at our Linux machine and let's try out a do wild script.
Let's clear the screen where we are.
We are in my script rectory, which is the directory we wanted to be in.
And this time we're going to create a new script and we we're going to call it script Do well.
Again.
It's just the name I'm picking.
You can pick anything you want.
Hit enter.
You are in VIP mode.
You hit insert and you start typing.
What's the first thing that you type?
You type hash bang bin bash, which defines your shell environment.
And if you wanted to put a comment, you can say this script is created by Ron F, so on.
2018.
Yeah, that's fine.
And if you wanted to put a description of the script, you could do that.
But let's get into the script.
I have already written down a script and I'm just going to go in and copy it.
There are two scripts in my handout.
I'm going to take the second one.
I want you to do the first one yourself.
I'm just going to copy it and I'm going to paste it real quick.
Let's see what the script does.
The script is doing, of course, the first one is defining the shell, which we already have.
So we're going to take it out by hitting D, and then it's telling us that the count is zero, the number
is ten, while the count is less than ten.
Do echo number of seconds left to stop this process.
And the process is the variable, which is dollar one.
And Echo is just an empty space.
Empty line.
Sleep.
Sleep is a command that will wait for the number of seconds that is defined after the sleep command.
Then it has a few number of expressions.
These are the expressions you could get at anywhere online.
I have that expression for a while that I tried out many times in my work environment.
It works perfectly and if you want to use it in your work environment, you are more than welcome to
do so.
The next one is the Echo and then it says Echo dot to one process is stopped and echo again.
It is telling it that it's giving an empty line.
So let's run the script and let's see what it does.
Give an executable permissions.
It this 10 seconds left to stop this process.
Nine, eight, seven, six, five, four, three, two, one.
And done process is stopped.
You see that?
So these do while scripts are created for a certain value or certain time to be met.
And once that variable is met, it will stop the process and exit out of it.
I want you to create a new script in your environment.
And this is the script again.
This is also in the handouts.
You can copy and paste the script, create a new script and run it.
You could also be my guest to go online and just type do wild script examples.
There are tons and tons of do well scripts that you could try and get get a little exposure to do what
scripts.
I'm sure by the time you will run at least five or six scripts, you know exactly what this statement
do.