1 00:00:00,120 --> 00:00:04,920 OK, so now that we, you know, got past some of the basic command stuff, let's talk about scripting 2 00:00:05,040 --> 00:00:05,600 basics. 3 00:00:06,060 --> 00:00:11,510 So actually, actually the language that used to navigate Nesquik commands in Linux. 4 00:00:11,700 --> 00:00:17,370 So all of the demands that, you know, we've learned so far actually use the scripting with no modifications 5 00:00:17,370 --> 00:00:18,220 in them whatsoever. 6 00:00:18,540 --> 00:00:22,380 So congrats, because, you know, better scripting now. 7 00:00:23,190 --> 00:00:28,020 So all you need to do is use those commands as a basic knowledge of Basche syntax. 8 00:00:28,290 --> 00:00:32,370 And we're going to have the automating processes in no time like anything that we did. 9 00:00:32,400 --> 00:00:37,560 Now, you can literally do that with a through so you can open up your preferred editing application 10 00:00:37,830 --> 00:00:41,280 and, you know, get to work on some of the stuff that I'm about to show you right now. 11 00:00:41,790 --> 00:00:43,210 So here's the basics. 12 00:00:43,210 --> 00:00:49,950 So all backslaps typically start with this Paon in an exclamation point, slash slash bash, and that's 13 00:00:49,950 --> 00:00:52,010 at the top of the file. 14 00:00:52,100 --> 00:00:54,450 You're going to create an actual best script as a file. 15 00:00:54,720 --> 00:01:00,320 So you're going to want to make sure that this is at the top every time that you make a battlegroup. 16 00:01:00,600 --> 00:01:05,190 Dispersion tells the system what it's going to run this file with. 17 00:01:05,190 --> 00:01:08,460 But this could be slash being slash python or something. 18 00:01:08,460 --> 00:01:09,470 It was Python. 19 00:01:09,480 --> 00:01:10,950 But right now, who needs Basche? 20 00:01:10,950 --> 00:01:14,960 So that's what it's going to interpret all the following lines of code are as. 21 00:01:15,180 --> 00:01:19,170 And just remember that the fans are going to execute in the order that you put them in. 22 00:01:19,680 --> 00:01:24,690 If you want to declare it variable, you do the variable name equals and then your value. 23 00:01:25,470 --> 00:01:29,820 If you want to access it, you would just write a dollar sign followed by the variable name. 24 00:01:30,500 --> 00:01:37,200 If you want to print something out, you know, on the screen, you would just write Echo and then the 25 00:01:37,200 --> 00:01:41,090 parentheses and put your text in there or you echo and the new variable name. 26 00:01:41,100 --> 00:01:47,370 So let's go try some really great Lizzio, but a new file and V Basche practice. 27 00:01:47,400 --> 00:01:50,250 OK, so we're going to go on to answer mode. 28 00:01:50,700 --> 00:01:56,460 Remember we start close to the Palestine exclamation point, slash bean slash fast and now he knows 29 00:01:56,460 --> 00:01:58,350 to interpret this as a bad script. 30 00:01:58,830 --> 00:02:08,850 So we make a variable called this class and then we're going to be equals and we can do single quotes 31 00:02:08,850 --> 00:02:10,020 right here or double quotes. 32 00:02:10,200 --> 00:02:16,770 I want to say this class is super fun. 33 00:02:19,630 --> 00:02:25,060 And I'm going to tell my friends about it. 34 00:02:25,630 --> 00:02:28,540 There you go to make sure you do that. 35 00:02:29,740 --> 00:02:34,660 So now let's go down and let's actually access this variables. 36 00:02:34,670 --> 00:02:41,680 So echo dollar sign and then the variable names of this class. 37 00:02:42,250 --> 00:02:44,680 So now hit escape right quick. 38 00:02:45,370 --> 00:02:47,620 Bam, Alice. 39 00:02:48,220 --> 00:02:49,380 Now, what are you going to see? 40 00:02:49,380 --> 00:02:50,770 Is that the best practice? 41 00:02:51,070 --> 00:02:53,080 I actually does not have execution. 42 00:02:53,080 --> 00:02:53,230 Right. 43 00:02:53,260 --> 00:03:00,300 So what we can do is a mild shortcut, which would be Siegmund plus X and then the name of the file. 44 00:03:00,340 --> 00:03:01,820 Best practice, bam. 45 00:03:02,110 --> 00:03:05,820 And now the color changes and we have actually execution access. 46 00:03:06,070 --> 00:03:10,900 So the way that we can run this bash is done slash best practice. 47 00:03:12,340 --> 00:03:14,740 And hey, it echoed out. 48 00:03:15,220 --> 00:03:18,370 This class is super fun and I'm going to tell all my friends about it. 49 00:03:18,380 --> 00:03:20,650 So make sure that you guys do that right. 50 00:03:21,370 --> 00:03:23,650 So that's just like some basics in the syntax. 51 00:03:23,860 --> 00:03:25,920 So now let's go over functions in bash. 52 00:03:26,320 --> 00:03:30,220 So to create a function and bash, it's going to look like this. 53 00:03:30,220 --> 00:03:35,770 You had the function name and then two parentheses and then these curly braces and then you put your 54 00:03:35,770 --> 00:03:39,550 commands for the function inside of it and all the function. 55 00:03:39,790 --> 00:03:41,280 You just type the function name. 56 00:03:41,330 --> 00:03:42,560 It'll do the function. 57 00:03:44,020 --> 00:03:50,140 So if you want to create a function that takes in an argument from the command line, so you just get 58 00:03:50,140 --> 00:03:53,990 the function name again and then echo. 59 00:03:54,460 --> 00:03:55,930 So here we have Echo. 60 00:03:55,960 --> 00:04:04,460 This is the random number today is and then it has signed one so that on one sets the argument given 61 00:04:04,460 --> 00:04:06,490 that the command line to that variable. 62 00:04:06,490 --> 00:04:06,650 Right. 63 00:04:06,820 --> 00:04:12,580 So whatever the first argument that you input at the command line after you put dot slash and then the 64 00:04:12,580 --> 00:04:19,120 filename and the space and maybe you type in something else, like you type in like a random number, 65 00:04:19,120 --> 00:04:22,900 it would actually use that as the variable. 66 00:04:23,080 --> 00:04:30,670 And we can you for this one specifically, we could just use the random variable which is in Gibby and 67 00:04:30,670 --> 00:04:33,650 Linux by default, and you'll be able to just pass on a random number. 68 00:04:33,680 --> 00:04:36,510 So let's actually go and try to make this OK. 69 00:04:36,520 --> 00:04:40,600 So I'm just starting to follow the bash function. 70 00:04:43,950 --> 00:04:50,560 So remember, we have to start with the policy points has been bash and then we can go down. 71 00:04:50,580 --> 00:04:56,010 So I don't want to do as going to set a variable equal to our first argument that we're going to pass 72 00:04:56,100 --> 00:04:56,370 in. 73 00:04:56,730 --> 00:05:03,280 So numbers that equal time once and now, the name of our function, which would be pass argument, 74 00:05:03,300 --> 00:05:07,470 I say that parentheses and curly braces. 75 00:05:07,740 --> 00:05:17,940 So now say echo today's user provided no is 76 00:05:20,280 --> 00:05:24,390 and then you can put no. 77 00:05:24,660 --> 00:05:25,320 There we go. 78 00:05:25,470 --> 00:05:26,020 Right there. 79 00:05:26,760 --> 00:05:29,760 So Cityscape quit. 80 00:05:30,600 --> 00:05:31,430 Well actually sorry. 81 00:05:31,680 --> 00:05:36,940 Before we do that, of course we have to call the function which makes sense. 82 00:05:37,320 --> 00:05:39,420 So let's go ahead and call the function. 83 00:05:39,630 --> 00:05:48,060 So pass argument is all you have to do is makes quit, give execution access. 84 00:05:48,480 --> 00:05:54,230 Sejima plus Xpress function there. 85 00:05:54,490 --> 00:06:01,980 Oh so dot slash function and let's say seventy six five for every go. 86 00:06:02,230 --> 00:06:05,470 Today's provision provider number is seven six five four. 87 00:06:05,640 --> 00:06:08,940 So now you know kind of like the basis of creating a functioning Basche. 88 00:06:09,140 --> 00:06:12,570 OK, so now let's go over capturing user input. 89 00:06:12,810 --> 00:06:19,980 So the input from user and stored as a variable we would use the Grand Redzepi, whatever text you want 90 00:06:19,980 --> 00:06:26,850 to print out, and then a variable name and read input from user solidly from passwords stored is variable. 91 00:06:27,060 --> 00:06:29,250 You would say redoes Espie. 92 00:06:29,430 --> 00:06:33,270 They need this X you wanted to print out and then followed by the the variable name. 93 00:06:33,840 --> 00:06:35,910 OK, so now let's go try this out really quickly. 94 00:06:36,030 --> 00:06:39,830 OK, so I'm going to start a new file, the C v input. 95 00:06:40,080 --> 00:06:40,710 Keep it simple. 96 00:06:41,040 --> 00:06:46,210 So let's put our command here first slash bash. 97 00:06:47,400 --> 00:06:59,610 So now let's do read the SPI username, keep the symbol and per user as the variable when a star dies 98 00:06:59,610 --> 00:07:07,930 and read Espie password pass W.D.. 99 00:07:08,670 --> 00:07:12,650 So now we have we can echo these because the story's variables now. 100 00:07:12,660 --> 00:07:16,290 So let's say now this echo, you know. 101 00:07:17,010 --> 00:07:17,910 Thanks. 102 00:07:19,880 --> 00:07:30,700 Or say thanks and then username, so say thanks, user, your password is now password. 103 00:07:30,740 --> 00:07:43,690 There you see my plus X and puts type wrong sige plus X inputs. 104 00:07:44,450 --> 00:07:46,130 Got such input. 105 00:07:47,450 --> 00:07:48,770 Not as from your username. 106 00:07:48,770 --> 00:07:51,080 So Anthony password. 107 00:07:51,800 --> 00:07:52,560 Password. 108 00:07:53,870 --> 00:07:54,710 Thanks Anthony. 109 00:07:54,770 --> 00:07:59,270 Your password is not password they so now you're not taking user input. 110 00:07:59,630 --> 00:08:04,580 And I'm just going to give you guys an example of, you know, a conditional statement in Basche really 111 00:08:04,580 --> 00:08:05,060 quickly. 112 00:08:05,450 --> 00:08:10,250 So when you see, you know, dash alti that means less then. 113 00:08:10,250 --> 00:08:13,800 And then if you see Dash G.T., that means greater than. 114 00:08:13,820 --> 00:08:15,890 So this one is asking you. 115 00:08:15,890 --> 00:08:18,260 So it takes your input, ask you how old you are. 116 00:08:18,350 --> 00:08:19,220 So what's your age? 117 00:08:19,610 --> 00:08:27,890 And then it says if the variable age is less than 16, then you're going to echo you are young or else 118 00:08:27,890 --> 00:08:30,740 if which is like saying like another if statement. 119 00:08:31,010 --> 00:08:36,010 If the age is greater than 60, we're going to say, hey, we're going to print out your mature. 120 00:08:36,440 --> 00:08:42,170 Other than that, we're going to go out, you're in the middle and then fee and the additional. 121 00:08:42,620 --> 00:08:46,100 OK, so that's like, you know, kind of basic of that. 122 00:08:46,220 --> 00:08:51,230 So and that's, you know, Basche kind of in a in a nutshell, you know, it's a lot of conditional 123 00:08:51,230 --> 00:08:56,870 statements and just using a different syntax and commands to execute things that you want to do this, 124 00:08:56,900 --> 00:09:00,410 it can go a lot deeper than we did and you can go out and learn that on your own. 125 00:09:00,410 --> 00:09:02,320 But that's pretty much the basics of Vash.