 Okay, we've made it. So we've been working the last two weeks. I've been showing you techniques and different tools that I use commonly in my scripts. Now we're going to start looking at some scripts I've created that I use daily to make life a lot easier. I'm going to go through a script that I've already created, and I'm going to not go into detail because all the details are in all the previous videos, but I'm just going to explain how the script works. This script will also, I'll try to remember to put a URL to the script in the description of this video so you can download and use this script. But let's go ahead and have a look at it. For me, I call it MAGA IMG. So again, this is the website here. We talked about it in the last video, and I talked about how to use curl to upload an image of that. But let's make it super simple because before, this was the command we had to run, and we had to tell it which image we wanted, and the type of image it is. Well, my script takes care of all that, so let's have a look at it. So at the top of the script, I have the shebang line saying this is a bash script, and then I have my copyright information, it's a GPL version three, license that I put this under, and we have a main function. If we go to the bottom of the script, you can see that I call the main function. Remember what this dollar sign at symbol means? We talked about that a few videos ago. This means all the arguments that you pass to it when you run the script. So you run the command, in my case I called it MAGA IMG, and then I give it some arguments. And so we're passing all those arguments to the main function. If we go back up to the top of our file here, you can see our main function here. First thing it does is it runs the check function, and again passes all those arguments that were now passed to this function. Let's have a look at our check function. So the check function, the main part of this is gonna be using get op, which I did a whole video or two on. And it's gonna look through all these options, q, c, n, and i. And the i has this colon after it. And what that means is I should have some sort of string after it. In this case, it's gonna be a file name. And then it's gonna use a case statement. It's gonna look through each one of those. And if you gave it the i option, it's then gonna take the IMG variable and put whatever string you put after the i there. And again, this will be, in this case, the file name. If you put c, we're gonna set c to true. And you can see what you're doing there is I put comments here. I don't always do that, but at this time, it's putting the link that's going to be returned to where your image is that you're uploading into your clipboard. If the q option is set, then we're gonna set qr to true and that will display a qr code. And you need to have qr and code installed. And then the option will also send a notification to your desktop. If you give an option that is not one of those options, it's going to run the help function and then exit with one. Meaning that it's exiting with an error that the script did not continue successfully. So let's go ahead and look at our help function here. It's just some text. Remember, we use the cat. And then we're doing the less and less than EOF to print multiple lines of text. So we're printing this message on how to use this script. So if you put an invalid option into the arguments when you're running the script, it should display this message. Remember the dollar sign zero will give you the name of the script. So even if the user renames the script, it will print the proper name of the script here. And it will give you how the usage is used and then give you an example and an explanation of each of these arguments. So now going back up to our check function. So that was our help. Again, if you get nothing else that's something that's not one of the proper arguments, it will run that help function and then again, exit before continuing. Next, so it's going to check through each one of these. After you check each one, you got to tell it to shift to the next one. Then we're going to check, okay, is image set? Because this script does nothing if you don't tell it what file you want. So if IMG is blank, we're going to say no input file and we're going to exit with an error. Because this script did not execute properly. After that, we're going to continue and we're going to get the meme and set that to a variable. So we're going to use our file command. So remember we're using dollar sign parentheses. So anything in this is going to be the output of this command is going to be put into this variable. We're saying to use file to get the meme type of the image that we've told the script to use. We're going to pipe that into Oc and get the second column. So we're getting just the meme type. And we're seeing that again into the meme variable here. And then right here, I'm putting the URL, which really, I'm not sure why I put that here. I probably should have put that up here at the top of the script, because that's a global variable for the script. It's not going to change. I'm not sure why I put that there, but I did. Okay, so now that we did that, we've collected the image name. And then we set these to true if those options were given. And you can give one or more or none of these options. The I option obviously is needed. So then you would go back to the main function after the check is done running, and it will run the upload function. The upload function then is going to run our curl function from our previous video. And in there, it's going to paste in the image file name, which is this variable here, the meme type. So again, if we can pass it a JPEG, a PNG, a GIF, or whatever file formats the website accepts, it will put the proper meme in there. And then the URL, which is set right here. Again, I'm not sure why I put that right there, but I did. And then it's going to return the location of your image. So it's going to upload your image. The website's going to give you back some information. We're going to look through that information, grab. Where is that image now on the server? And we're going to put that in this link variable here. Then we're going to display that. We're going to echo that out. So our script will say, here's the URL. This is where your image is. Next, we're going to check. So these brackets, and don't forget these spaces. This is a very short way of doing an if-then statement. We're saying, if this is true, or if this is true, and then they, so this is going to return true or false. The ampersand, ampersand, that's saying, okay, if the last thing is true. So if this is true, then we're going to run QRN code. We're going to give it our link, and we're going to use Unicode as the output. So it's going to output, if we want, the URL in a QR code. So we can run this. Not only we'll display the URL on the screen, but we can tell it to display the QR code right there in the shell. I can point my phone at it, and now my phone will open up that image. Another option is the N option, if that's true. Then we're going to send a notification to my desktop. Going to display it for three seconds. It's going to say the image was uploaded. And again, give the URL that we retrieved. Now, we're going to put it in the clipboard. Well, if you set the C option, it's now going to use X clip. And it's going to, I've set it to where it takes the URL, and it's going to put it in both my clipboards. So now I can either, as soon as I run the script, I don't even have to, even though it's displaying it to the shell, I don't have to highlight and copy it. I can just center click anywhere, and it will paste that URL, or I can control V or control shift V if I'm in the shell, or right click and paste, or edit and paste. All those options will now work and paste the URL. Once we're done, it's going to exit with zero, meaning that everything was successful, hopefully. So let's go ahead and exit out of the script, and I'm in a folder with a bunch of photos of my son. And I decided to grab photos of my son because my daughter's been on my YouTube channel a couple of times, and I want to get my son some love, so I got all these pictures of him. Let's go ahead and run our script, which again, in my case is called mega image, or mega image, and I will give it one of these file names. I will give it this file name. And if I just do that, well, it's going to give me an error, no file input, because we got to give it the dash I option. Do that, and we should get the URL of where that image is. And now we can also run it again, and give it a different image. Boom, and now we got a different URL. Now we can give it the, well, if I say H, or really anything that's not valid, it's now going to print out the help file, so I can see all my options here. And again, that dollar sign zero lists out the name of my image. It actually gives the full path. Actually, I was thinking about, I don't think I've done this trial yet on actually, yes, that's right, because I'm going to do one. You can use base name to get the base name, or you can use pure bash, which I'm going to get to in a future video. Anyway, we now see our options. And again, so now we know we want to do I in the file name, but I can also do C. So now it uploads the image, and I gave it the same image as we talked about in the previous video, so it gives the same URL, but if I was to give it one of the other images, let's just choose that one. It's going to print the URL there, but it's also in my clipboard now, so I can center click and it's going to paste that URL. Or I can control shift V in the shell here and it'll paste that URL. So it's automatically in both my clipboards when I use that dash C option. The next option is the dash Q option. So I can say the name of my command dash CQI and give it a file name. And let's go ahead and just give it a different file name. We'll do this one, boom. So it's printed to the screen, the URL. It's giving me a QR code that I can now scan my phone and you should be able to in this video as well. So I should looking at it with high enough resolution. So I can pick up my phone right now, boop! And it will open up that image on my phone. And I also have it in my clipboard where I can paste that URL. Next option would be the notification option. So I can now add an end to this option. So I do end, boom. Once it runs, you can see I got this notification here and it will be up there for three seconds. And I have my system set up. So let me go here so that's not full screen anymore. I can run that command. And if I hit control shift I, or control shift period I can then hit enter and it actually will open up that image in my browser. So let's go ahead and run that command again, giving it a different image. We'll do, I don't know, this one here. And again, I can go control shift period and hit enter and it will now open up. And that's just how I have the shortcuts I have set up for my instance of guns, which is my notification damon. So that's very useful. If depending on what notification service you use, you might be able to click on that to open it. It all depends on how you have your setup. But since we're using notify send, which works with a variety of notification services, it should at least pop up there, it should still work. So those are our options. And again, we can give any variety of them. I can just do PR. So now it's not going to my clipboard and I don't get the notification. I can just say notification and it pops up there, which is very useful. So that is the script. And it's very useful to quickly upload an image. And again, I can have it go straight to my clipboard. I can have a QR code. So if I want to get my phone, but if I wanted to send it to somebody, I can just, you know, I can do this, boom, it ran. I can now paste that into a text and email or whatever. And some will have a link to that image. So it's fairly simple script. Once you know how everything works and if you watched the previous two weeks of videos I put out, I think I went over everything in that video in detail. So if you didn't understand anything, watch the previous videos that I put out before this. I hope that you enjoyed this video and we're gonna be looking at more scripts I wrote similar to this to make life easier. So thanks for watching. Please visit filmsbychrist.com, that's Chris the K. The link in the description. There you can search through all my videos. You can also go to my software section where you can click on my Git lab account, see my projects there. Scripts will bring you to my website where I have a list of scripts that you can run right in your web browser and my notes which search through all my pastes then which this script will be there. So I should put it in the description of this video. So you can search there, but if not, once it's uploaded, actually it might already be uploaded. Here, there you go. Here's the script right there because I've already backed it up. And yeah, go check it out there. And yeah, I'm using Payspin. I really should be using something a little bit better than that, but that's what I've been using for years so that's still there. Thanks for watching. Again, filmsbychrist.com, like, share, subscribe, comment, support, all that stuff. Thanks for watching. Have a great day.