 Hello, and welcome to the series on seed programming. Today, we're going to be looking at something that you probably shouldn't do too much, but it you need to do something quick and easy. It can be useful. We're going to call system commands from our C code. So normally when you write something in C, you try to write something in a lower level language. So you want to be more efficient, so you're not writing scripts, but sometimes it's just you don't want to write out the functions yourself. It's just a quick and easy way to do something, but again, if you're writing in C, you probably isn't your first goal to do this. That being said, I do it all the time. Let's go. Vim system C is what I'm calling our code file, and in here we have a very basic function here. This is important. We got our standard lib.h here. You need that to do a system call. We got our main function returning zero here. And what we're going to do is we're just going to type in system. And inside of the parentheses for this, we're going to give our command. And I'm just going to do a list command on my root directory here. So we're going to do that. Get out of that. I'm going to say gcc, our code file dash output, I'll just call it system. And then I'm going to dot slash to run system. And it lists out the files in my root directory. Let's give it another example. Let me come in here and I'll run the date command. So I'll just type in date in here. I'll recompile that with gcc. I will run it again, and now it prints out the date and time. I can even use the echo command, which would just be silly since you have the print f command in our function in C. But we can say, oops, echo, hello world. I can save that and I can compile it and run it and it says hello world. And of course you can do more than one thing. I can, in one command here, I can say date and then semi colon and I should be able to compile that and run it. And it's just like typing it at the shell. So we have our date and then hello world and of course you can also have a system command called more than once. I can come in here and I can say system and I can in here list out my root directory if I could type properly today. There we go. So now I can compile that. I can't run it and it gets the date, hello world and then lists the files from my root directory and of course we can also add options to that. I can say LHA as some switches for that and I can run that now and you miss the first few commands here but it gets the date, hello world and then runs that list command. So again, if you're writing in C, most of the time you're not going to, you're looking to do things a little more efficient but sometimes it's useful. Maybe you want a binary for some reason but do be aware you're not like really hiding anything if that's your goal because if I just run the strings command on our system binary here it gives out all the strings and I can then grep for something like list and you can see that the commands are in there in plain text. So if your goal is to hide commands in a binary file you might trick some people but not most people. Let's see, date, is that, yeah, so date, echo world, you know, so it would not be hard for someone trying to back read engineer your binary to find the commands you're running so you're not hiding stuff that way. Anyway, it is useful at times and yeah, this was a quick short one. I hope you enjoyed it and I hope that you have a great day. Please visit filmsbychrist.com. That's Chris Cade, there's a link in the description.