WEBVTT

00:00.560 --> 00:00.880
Okay.

00:00.880 --> 00:07.680
In the previous package, we, uh, created our application for changing a mac address, and it is working

00:07.680 --> 00:08.520
perfect.

00:08.920 --> 00:11.760
So now let me collapse this.

00:11.800 --> 00:15.080
Okay, so here we have two function get argument.

00:15.080 --> 00:17.040
And also changing the Mac address.

00:17.640 --> 00:19.640
It is asking to argument.

00:19.680 --> 00:22.600
Okay for interface and new Mac address.

00:23.920 --> 00:25.760
And we are calling those two.

00:25.800 --> 00:27.160
Here we are using it.

00:27.560 --> 00:36.040
Now let me uh create our before creating okay I will do something here.

00:36.240 --> 00:40.160
So here we are going to design an algorithm okay.

00:40.200 --> 00:42.080
For changing the Mac address.

00:42.440 --> 00:46.800
So first thing we ask what is an algorithm okay.

00:46.840 --> 00:52.440
An algorithm is steps of writing a program okay.

00:53.120 --> 00:59.040
We write an application or a program in many steps to solve a problem.

00:59.040 --> 01:00.870
So that is called algorithm.

01:01.430 --> 01:07.870
Now we are going to design an algorithm here to change the Mac address.

01:08.030 --> 01:12.790
So what is the those steps that we want to do.

01:12.830 --> 01:13.910
Okay.

01:13.950 --> 01:21.910
So the first step is to execute and read ifconfig.

01:21.950 --> 01:22.350
Okay.

01:23.070 --> 01:29.110
Execute and read ifconfig.

01:29.270 --> 01:29.670
Okay.

01:30.790 --> 01:33.790
And what is the second part.

01:34.990 --> 01:41.670
Second step it is to read the Mac address from the output as you see here.

01:41.710 --> 01:42.110
Okay.

01:43.470 --> 01:45.670
While we are trying to change the Mac address.

01:45.870 --> 01:48.150
First we use ifconfig okay.

01:48.430 --> 01:52.430
So the first part is to write ifconfig.

01:52.430 --> 01:59.310
And then I like this like here to read the command from output okay.

02:00.620 --> 02:03.100
So this is going to be read Mac address.

02:03.140 --> 02:03.540
Okay.

02:04.580 --> 02:05.860
Read the Mac address.

02:07.780 --> 02:08.220
Okay.

02:08.620 --> 02:09.620
From output.

02:11.500 --> 02:19.260
And we have the next part which is the third part or the third section or the third step.

02:19.260 --> 02:25.140
In here we are going to check if Mac address in ifconfig is what the user requested.

02:25.180 --> 02:26.060
Okay.

02:26.100 --> 02:26.820
Very easy.

02:27.060 --> 02:28.700
So here we just check it.

02:28.740 --> 02:29.300
Okay.

02:29.340 --> 02:42.540
Check if Mac in ifconfig is what is what the user requested.

02:44.660 --> 02:46.420
So this is the third part.

02:46.460 --> 02:51.820
And also the final part is going to be the fourth one.

02:52.180 --> 02:55.220
And here we are going to print an appropriate message.

02:56.020 --> 02:56.900
So let's say.

02:59.810 --> 03:01.730
Appropriate message.

03:02.130 --> 03:03.050
Okay.

03:03.090 --> 03:09.290
So in this four step we are going to write an algorithm here.

03:09.330 --> 03:09.730
Okay.

03:10.330 --> 03:14.130
To do this to get the goal.

03:14.130 --> 03:19.810
The goal is to check if Mac address is changed or not.

03:19.850 --> 03:20.370
Okay.

03:20.370 --> 03:21.210
Very easy.

03:21.610 --> 03:23.530
So here I am going to.

03:25.970 --> 03:30.450
Uh I'm going to use a function called check output.

03:30.490 --> 03:31.410
Okay.

03:31.450 --> 03:35.930
And it is from this subprocess here I'm going to check that okay.

03:35.970 --> 03:43.050
I'm going to use that to check if uh we are executing the ifconfig or not.

03:43.210 --> 03:43.610
Okay.

03:43.810 --> 03:49.490
So let's do that here I'm going to use subprocess dot check.

03:50.290 --> 03:52.250
Output is a function okay.

03:52.290 --> 03:54.770
That belongs to the subprocess.

03:54.770 --> 03:58.550
And here inside this I'm going to give the give the command.

03:58.590 --> 03:58.790
Okay.

03:58.830 --> 04:00.270
So I'm going to use a list.

04:00.510 --> 04:02.150
So it is going to be ifconfig.

04:02.470 --> 04:05.630
Ifconfig ifconfig okay.

04:05.950 --> 04:07.470
And what is the second one.

04:07.670 --> 04:09.710
And you know it is the name of the interface.

04:09.750 --> 04:10.150
Okay.

04:10.350 --> 04:13.870
For example we have LAN zero, we have eta zero.

04:14.190 --> 04:15.270
And a lot of things.

04:15.310 --> 04:15.710
Okay.

04:15.910 --> 04:21.630
But here we are going to use options dot interface.

04:23.830 --> 04:24.230
Okay.

04:24.430 --> 04:25.230
That is here.

04:26.710 --> 04:29.830
And finally we are going to print this okay.

04:30.030 --> 04:31.990
So let's use print.

04:33.830 --> 04:34.710
Print what.

04:34.750 --> 04:35.070
Okay.

04:35.070 --> 04:39.790
Let's first store this into a variable I'm going to name it ifconfig result.

04:39.830 --> 04:40.230
Okay.

04:40.830 --> 04:43.830
Ifconfig underscore result.

04:43.870 --> 04:45.990
It is assigned to this.

04:45.990 --> 04:48.990
And here I'm going to print that.

04:51.030 --> 04:53.550
And also I'm not going to change the Mac address.

04:53.590 --> 04:54.030
Okay.

04:54.030 --> 04:57.740
So let's comment that and save it.

04:58.100 --> 04:59.140
Let's come back here.

04:59.500 --> 05:01.380
I'm going to clear it.

05:01.500 --> 05:01.900
Okay.

05:02.620 --> 05:08.660
And here, right now, I am trying to change the Mac address for eth0.

05:08.700 --> 05:11.700
Okay, now, let's, uh, while I'm hitting enter.

05:11.700 --> 05:14.780
So it must print the result of ifconfig for me.

05:16.180 --> 05:16.740
Okay.

05:16.860 --> 05:21.300
As you see, it is printing the ifconfig for me, and that is eth zero.

05:21.340 --> 05:21.820
That is.

05:21.980 --> 05:22.260
Here.

05:22.260 --> 05:23.140
You see it okay.

05:24.860 --> 05:27.620
And let's see what else do we have.

05:28.220 --> 05:29.460
Where is the Mac address.

05:29.500 --> 05:30.660
That is either here.

05:30.700 --> 05:31.540
Okay.

05:31.580 --> 05:32.340
This is it.

05:32.900 --> 05:41.580
So right now you see we are changing the we're trying to get the output, uh, trying to execute the

05:41.620 --> 05:42.140
writ.

05:42.700 --> 05:43.540
Uh, ifconfig.

05:43.580 --> 05:43.740
Okay.

05:43.740 --> 05:45.060
Execute and read f config.

05:45.260 --> 05:48.740
So this is the first part that we have done it okay.

05:48.780 --> 05:54.180
The second or the next part or the next step is to read Mac address from output.

05:54.580 --> 05:57.060
So let's go and do that in the next video.
