1 00:00:06,480 --> 00:00:08,910 - All right, let's write a script. 2 00:00:08,910 --> 00:00:10,230 What do we need to do? 3 00:00:10,230 --> 00:00:13,770 The script should prompt for the user to enter a color 4 00:00:13,770 --> 00:00:16,620 and the name of this color should be stored in a variable. 5 00:00:16,620 --> 00:00:18,390 And the script should loop in such a way 6 00:00:18,390 --> 00:00:21,517 that every 10 seconds, it'll prompt for the message, 7 00:00:21,517 --> 00:00:22,890 "The color is on screen" 8 00:00:22,890 --> 00:00:25,440 and ensure that instead of whatever, 9 00:00:25,440 --> 00:00:28,110 the actual color name is printed. 10 00:00:28,110 --> 00:00:30,900 Start the script in a way that it takes a lower priority 11 00:00:30,900 --> 00:00:33,963 than other processes running on your computer. 12 00:00:35,010 --> 00:00:36,033 Okay, let's do it. 13 00:00:39,030 --> 00:00:42,033 So I'm calling this script color.sh. 14 00:00:43,320 --> 00:00:45,960 The assignment is not mentioning any names, 15 00:00:45,960 --> 00:00:49,200 so I'm figuring out something myself. 16 00:00:49,200 --> 00:00:51,180 A script should always start with shebang, 17 00:00:51,180 --> 00:00:53,160 so there we go. 18 00:00:53,160 --> 00:00:56,877 And then, "echo enter a color". 19 00:00:59,077 --> 00:01:01,050 "read COLOR". 20 00:01:01,050 --> 00:01:05,070 That will create the variable that the user is entering. 21 00:01:05,070 --> 00:01:06,660 And then we need the script to loop 22 00:01:06,660 --> 00:01:08,340 in such a way that every 10 seconds, 23 00:01:08,340 --> 00:01:10,530 it'll prompt a message "The color is". 24 00:01:10,530 --> 00:01:15,530 So "while sleep 10, 25 00:01:17,490 --> 00:01:18,780 do 26 00:01:18,780 --> 00:01:22,720 echo the color is $COLOR 27 00:01:23,700 --> 00:01:24,533 done." 28 00:01:26,130 --> 00:01:27,183 That seems to be it. 29 00:01:28,140 --> 00:01:29,610 And then we need to start a script 30 00:01:29,610 --> 00:01:31,620 in such a way that it takes a lower priority 31 00:01:31,620 --> 00:01:34,203 than all the processes running on your computer. 32 00:01:35,430 --> 00:01:38,137 So, let's first make it executable, 33 00:01:38,137 --> 00:01:42,990 "chmod + x color.sh" 34 00:01:42,990 --> 00:01:47,990 and then let's use "nice 19 color.sh". 35 00:01:51,630 --> 00:01:53,310 Oops, my mistake. 36 00:01:53,310 --> 00:01:55,140 That's why you should always check some help 37 00:01:55,140 --> 00:01:57,690 if you don't use it on a regular basis. 38 00:01:57,690 --> 00:02:00,810 And let me use "nice minus minus help" 39 00:02:00,810 --> 00:02:02,070 to see what we need to do. 40 00:02:02,070 --> 00:02:05,970 Ah, "nice minus minus n" 41 00:02:05,970 --> 00:02:07,770 followed by the 19. 42 00:02:07,770 --> 00:02:09,123 So, we were almost there. 43 00:02:13,620 --> 00:02:15,307 And then it's giving me an error, 44 00:02:15,307 --> 00:02:16,590 "No such file or directory" 45 00:02:16,590 --> 00:02:20,160 because color.sh isn't the current directory. 46 00:02:20,160 --> 00:02:21,423 But now we are good. 47 00:02:22,740 --> 00:02:24,813 So we need to wait for 10 seconds. 48 00:02:26,520 --> 00:02:27,353 And there we go. 49 00:02:27,353 --> 00:02:28,650 The color is blue. 50 00:02:28,650 --> 00:02:31,590 Feel free to wait another 10 seconds to verify 51 00:02:31,590 --> 00:02:35,640 that the while loop is doing what you expected to do. 52 00:02:35,640 --> 00:02:39,870 I would really advise you to see at least twice 53 00:02:39,870 --> 00:02:41,370 that it's working all right. 54 00:02:41,370 --> 00:02:44,070 Three times, if that makes you feel better. 55 00:02:44,070 --> 00:02:45,780 And if you're seeing it three times, 56 00:02:45,780 --> 00:02:47,433 then, you should be okay. 57 00:02:48,390 --> 00:02:49,563 Right, that's all.