Time
2 hours 57 minutes
Difficulty
Beginner
CEU/CPE
3

Video Transcription

00:00
Hello, everyone. And welcome back to intrude a python. You're on Sai Berry on demand. I as always I'm your instructor, Joe Perry. And today we're gonna be in lesson six. This is gonna be our second video of less and six where we're going to create an execute our very first python script. So if you were with us in the last video, you know that we performed a hello world
00:19
We printed hello world to the screen
00:21
by executing the following line of code
00:25
Retyped it real fast.
00:26
You think I could do You could have just left it up, but
00:29
oh, well, anyway, here's the line of Coby Ran Printed Hello, world. Now what we're gonna do is we're gonna take that line of code we're gonna turn it into a python script.
00:38
So first, and probably in a foremost we're gonna go ahead and quit. Are python show
00:43
We're gonna clear out of screen.
00:45
Now I'm going to be working in them for the rest of these videos. I love them as a text editor. I'm not really I don't generally go in for really big ID's.
00:54
It's sort of the same way that you know,
00:55
everyone has their own style. But a lot of authors actually prefer to write with typewriters or with old school word processing
01:03
tools that don't really have a lot of features on them. It's all about your style and what you know. I learned a program on a very simple basically exactly you see here text on a black screen, so that's what I'm comfortable with. That's what I like, and that's what I'm best at. So we're gonna work in vim
01:17
on for those who have never used them or those of you who just downloaded them. A useful piece of information is not really that relevant to this course. Other than that, it will make the rest of your programming a lot easier.
01:26
So if you go to, if you use them to edit the MRC file or the same configuration file,
01:33
which is going to be found generally speaking, in your etc. Them them. Our seat now, depending on your installation, depending on you know, the system you're on, it might be dot marcie.
01:42
In my case, it's just them r c.
01:45
So you can open that up and edit it Tight mate.
01:48
Super secure password in here
01:49
and you can see I've already got it down to the part of the page that is relevant on yours. If you haven't edited this, all of the lines that just disappeared for some reason. Here we go.
02:01
Come on.
02:06
There we go.
02:07
All of these lines right here. Those are configurations for them. That air probably commented out If you've not edited this s o, just go through and delete the quote. That's a beginning, and that'll enable these. Additionally, I also set auto and Dent, which you can see right here. And all that does is it makes
02:23
a CZ. We talked about it on our last video where pilot uses tabs, spaces, What have you
02:28
What it does is it takes whatever the indentation of the previous line waas and it takes us back to and it puts that on the new line. When you hit, enter
02:36
saves you just a little bit of typing. And it's one of those quality of life upgrades that I really appreciate.
02:39
Additionally, I'm going to go ahead and what should not be in visual anymore.
02:45
And I'm going to go ahead and find
02:47
our dark There it is
02:52
and set background equals dark. That just makes it a little bit easier to read on the dark background. So now I am in
02:58
wrong command DVD. I'm currently in less than six,
03:00
and we're going to create our very first Python script. So we were gonna do that, is gonna run the command of him, and I'm going to use the name H w dot p y. So, Doc P wise the python file extension that tells your shell that tells your operating system this is a python file.
03:17
It also tells your editor that this is a pipe on file. If you have syntax highlighting for
03:22
Python, so then in our file, all we're gonna do at first is we're gonna write this line
03:28
Wrong thing there.
03:36
Now, this line is actually not mandatory in Python. It is very useful, however, because it allows you to make your python script execute herbal.
03:44
I'll show you the two ways to run a python script here in just a minute. But by doing this, we call that a shebang. That's what these two symbols right here are that the depending on your generation that is either a pound sign. Ah, hash mark a comment Mark hash tag
04:00
point is that Mark right there that looks like a tic tac toe game. That and the exclamation mark together that's called a shebang. And that's just an indicator to the limits operating system that this is the This is a python doctor. This is a python script and that it could be run using the python three. Interpreter found in user Been
04:17
so
04:18
in the last video we were Hello, World. At the beginning of this video, I showed you how the world again from the command line To do that in a python script, all you have to do is write exactly that command again.
04:30
But now, instead of running automatically because you're in an interpreter because you're not in an interpreter rather instead of running automatically,
04:38
it's just text. It's just written to the document.
04:41
Once we read it, we can quit
04:45
how to run this. There are a couple of different possibilities. If we didn't have this your gangland, we could only do it by right by running the command Python three
04:51
and then the file name.
04:54
In which case band we've printed our first ever Hello world.
04:57
Yeah,
04:59
Weaken do
05:01
tomatoes Command that will set that file to be executed ble with the 777 setting the specific permissions that are basically just all permission.
05:10
Hello, world not pi h w not pie.
05:14
And you can see here
05:15
the color changed on it.
05:15
Uh, is now execute herbal
05:18
and then you can run it on your Lennox Coman are on your Lennox terminal just by doing dot, slash h w dot p y
05:26
dot slash just says, look in the current directory forthis
05:29
And there you go. Once again, we have run Hello world So either of those options work Most python programmers will include the line at the top of the file and make it execute a ble.
05:38
It's really all about your personal style. It's not mandatory, but it's very commonly used,
05:42
and that's all there is to it. In this video, we learned how to write Hello world. We learned how to take the python code that we were doing in the interpreter Put it in a document and run that document. From here on out, we're gonna be able to really do some actual python program. We're gonna spend all of our time in the b m. Very excited for it. Our next video is gonna be the last actual lesson of the last
06:00
informative video of module one after. That's just our review.
06:03
So tune back in. We're gonna talk about dir help and the python documentation. As always, I'm your instructor, Joe Perry, and thank you for watching intruder python on cyber eri on demand.

Up Next

Intro to Python

This is an introductory course on Python for cyber security, giving students the ability to understand the basics of the language, solve problems with scripts and identify useful Python modules.

Instructed By

Instructor Profile Image
Joe Perry
Senior Technical Instructor at FireEye, Inc
Instructor