Write a script that takes five arguments: • A command to run (which could be an executable compiled with gce). Note that it must be the exact command needed to run it, not just the executable's name (which is why you see ./test in the example instead of test). • A start integer A. • An end integer B. • A step integer S. • An output file. The script should perform a series of runs of the given command. The first run should have A be passed as argument to the command to run. In the next run, A+ S should be passed. After that, A +25, then A+3S, then A + 4S, and so on, until the value passed would exceed B. Each run's results should be logged into the output file. You may not assume this output file exists, and its old contents should be overwritten. The script assumes that the executable only takes an integer as its only command-line argument. If not enough arguments are provided, then a usage message should be printed and the script should return 1 (with exit 1); otherwise, the script should return 0. Below are some examples of how your script should behave. 1 $ cat test.c 2 #include <stdio.h> 3 G 4 int main(int argc, char *argv[]) { printf("Provided: %s\n", argv[1]); 7} 8 $ gcc-Wall -Werror test.c-o test 9 $ ./run_steps.sh /test 10 100 5 output1.txt 10 $ cat outputi.txt 11 10 SS 12 Provided : 10 15 ===
=== 14 Provided : 15 15 === 20 === 16 Provided : 20 17 === 25 === 18 Provided : 25 19 === 30 === 20 Provided : 30 21 35 22 Provided : 35 28 === 40 E 24 Provided : 40 25 === 45 === 26 Provided : 45 27 = 50 === 28. Provided : 50 29 === 55 === 20 Provided : 55 31 === 60 === 32 Provided : 60 === 65 === 34 Provided : 65 70 === 36 Provided : 70 37 === 75 === 38 Provided : 75 39 === 80 === 40 Provided : 80 41 === 85 === 42 Provided : 85 === 90 44 Provided : 90 === 95 === 46 Provided : 95 47 100 48 Provided : 100 49 $ ./run_steps.sh ./test 50 80 10 output2.txt 50 $ cat output2.txt 61 === 50 === 52 Provided : 50 53 60 54 Provided : 60 === 70 === 66 Provided : 70 57 === 80 58 Provided : 80 59 $ cat test2.c 60 #include <stdio.h> 61 #include <stdlib.h> G === === ===
62 66 67 68 63 int main(int arge, char *argv[]) 64 { int num = atoi(argv[1]); if (num < 100) printf ("Less than 100.\n"); else 69 printf ("Greater than or equal to 100.\n"); 70 } 71 $ gcc-Wall -Werror test2.c - test2 72 $ ./run_steps.sh ./test2 97 104 2 output 3.txt 78 $ echo $? 74 0 75 $ cat output3.txt 97 77 Less than 100. 76 BE 78 99 === 80 = 79 Less than 100. 101 81 Greater than or equal to 100. 82 103 - 83 Greater than or equal to 100. 84 $ ./ run_steps.sh ./test2 97 104 85 Usage: /run_steps.sh [executable] [start] [end] [step] [outfile] 86 $ echo $? 87 1