This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
haas:spring2014:unix:projects:dataproc [2014/03/23 19:24] – [Submission] wedge | haas:spring2014:unix:projects:dataproc [2014/03/23 21:29] (current) – [Submission] wedge | ||
---|---|---|---|
Line 12: | Line 12: | ||
=====Background===== | =====Background===== | ||
- | To most of us, computers are a frequently used interactive tool for accomplishing work. With our recent explorations into the realm of shell scripting, concepts of automation are starting to enter our peripherary. | + | Often times, we will find ourselves encountering data in a slightly one-off format- not quite meeting some requirement we need for further processing. |
- | With automation, comes the need to do things outside that interactive | + | Luckily, the UNIX environment |
- | We will be scheduling tasks with respect to time in this project, | + | This activity has you dabbling |
- | =====cron===== | + | =====Task 0: Post/ |
- | From the wikipedia article on [[wp> | + | * Because |
+ | * Please do not give away any answers to the actions requested by this project in doing so. | ||
+ | * Be sure to identify which " | ||
+ | * Respond to at least 1 question, not by giving an explicit answer, but by asking further questions, or giving a pointer to a resource that may contain additional information (i.e. see **cut(1)** manual page) | ||
+ | * To get credit, your response can**not** be to one of your own questions. | ||
+ | * Put a URL to the mailing list post of your question asked in a file called: **task0.question** | ||
+ | * See http:// | ||
+ | * Put a URL to the mailing list post of your response in a file called: **task0.response** | ||
+ | * See http:// | ||
+ | * A question may receive multiple answers. | ||
- | "Cron is a time-based job scheduler | + | =====Task 1: Obtain source code===== |
+ | On Lab46, | ||
- | Be sure to check the manual page for **cron**(**8**), | + | |
+ | | ||
- | =====Task | + | =====Task |
- | There exist a number of irc bots, consisting of varying features and complexities. To facilitate your task, I would recommend the using of Phenny (or a clone), which tends to be simpler to deploy than its more configurable counterparts. | + | |
- | So, via the proper means: | + | Determine: |
+ | * How to properly compile the file (so that it will run without displaying an error)? | ||
+ | * How to properly execute the resulting program (to generate 8 lines of output)? | ||
+ | * When you figure out the answers to both of these, put your responses in a file called **task2.txt** | ||
- | * Download a recent release | + | A copy of the code follows: |
- | * There' | + | |
- | * There' | + | |
- | * If it is obtained in archive form, extract it somewhere within your home directory (perhaps under **src/**) | + | |
- | * Take a look at the files obtained, start reading any documentation | + | |
- | =====Task 2: Configure irc bot===== | + | <code c 1> |
- | An irc bot, being a network-aware piece of software, needs sufficient configuration in order to operate properly. While it is up to you to derive | + | /* |
+ | * info.c | ||
+ | * | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | * | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | * | ||
+ | * To compile: gcc -o PROGRAM_NAME info.c | ||
+ | */ | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
- | | + | int main(int argc, char **argv) |
- | * the irc server you want to connect to is: **irc.offbyone.lan** | + | { |
- | * you may want to initially configure your bot to join a secluded channel so you can test it. For the project, it will ultimately need to join: **# | + | int index, |
- | * you should configure both yourself and me (username **wedge**) as administrators for the bot. | + | char name[] = { 0x64, 0160, (114-63), (064+03), 0x00 }; |
+ | char file[(strlen(name)+1)]; | ||
- | Verify you can successfully start the bot and that it connects to the intended server and channel. You may want to run it in a sub-console in your screen session, so that you can keep an eye on any messages it generates. | + | x = strlen(*(argv+0)); |
+ | y = strlen(name); | ||
- | =====Task 3: Enhance the bot with modules/ | + | for (i = 0; i <= y; i++) |
- | In addition to core usability, I'd like you to enable additional functionality through the use of modules. A few modules come with the stock Phenny software distribution, | + | { |
+ | file[i] | ||
+ | } | ||
- | * phenny-games | + | if (strcasecmp(file, |
- | * oblique | + | { |
+ | fprintf(stderr, | ||
+ | fprintf(stderr, | ||
+ | exit(1); | ||
+ | } | ||
- | Install and enable modules for your bot, and verify some form of functionality. | + | if (argc >= 2) |
+ | { | ||
+ | max = atoi(*(argv+1)); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | max = 0; | ||
+ | } | ||
- | **NOTE:** Due to changes in the service it uses, the Phenny **weather** module is beyond broken. Trying to use it will result in an error being displayed. If you are skilled with Python and can craft a solution, that can certainly count toward completing this task of the project. | + | if (argc >= 3) |
+ | { | ||
+ | srand(atoi(*(argv+2))); | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | srand(1730); | ||
+ | } | ||
- | =====Task 4: Script to check bot status===== | + | for (index |
- | Using tools and concepts we learned previously, especially: | + | { |
+ | x = rand() % 849 + 50; | ||
+ | y = rand() % 1899 + 100; | ||
- | * ps | + | if (((x % 3) == 0) && ((y % 4) > 2)) |
- | * grep | + | fprintf(stdout, |
- | * pgrep | + | else if (((x % 7) < 4) && ((y % 5) > 3)) |
+ | fprintf(stdout, | ||
+ | else | ||
+ | fprintf(stdout, | ||
+ | } | ||
- | Write a script that checks for a currently running Phenny instance | + | return(0); |
+ | } | ||
+ | </ | ||
- | Be sure to make use of **absolute paths**. | + | NOTE: Copying/ |
+ | =====Task 3: Execute your program===== | ||
- | =====Task 5: Script to kill running bot===== | + | Once you have things working: |
- | Using tools and concepts we learned previously, especially: | + | |
- | * ps | + | * Run the program and have it generate 1024 lines of output |
- | * grep | + | * Write down the command-line used in a file called |
- | | + | |
- | | + | |
- | | + | |
- | Create a script that will check for a currently running Phenny instance (run by you). If an instance is running, kill it. | + | =====Task 4: Store your output===== |
- | If no instance is running, do nothing. | + | * Save your program' |
- | =====Task | + | =====Task |
- | Reading up on cron and figuring out how to add an entry to your user's personal crontab, add a job that runs your check script | + | * Ignoring the index values in the left-most column, determine which numerical codes occur more than once by concocting |
+ | * Also display with a count of the total number of lines in the output, along with the total number of lines with valid numeric values (ignore " | ||
+ | * Put your resulting command-line(s) or script | ||
+ | * Put the output (result) of your command-line(s) or script in a file called **task5.out** | ||
- | You can verify successful cron job deployment by ensuring your bot is not running and waiting for the next 10 minute marker and see if it starts. | + | For example, let's say we had the following output: |
- | =====Task | + | < |
- | While cron is used for long-term scheduled jobs, **at** is useful for short term ones. | + | 1 671-477 |
+ | 2 error 4 | ||
+ | 3 742-703 | ||
+ | 4 671-477 | ||
+ | 5 blank | ||
+ | 6 516-336 | ||
+ | 7 671-477 | ||
+ | 8 742-703 | ||
+ | 9 546-031 | ||
+ | 10 089-322 | ||
+ | 11 442-1220 | ||
+ | 12 blank | ||
+ | </ | ||
- | Read up on **at**, and deploy an **at** job that will run your **botkill** script (task 5) a couple minutes before a 10 minute marker. | + | As a result of running your solution, the following output should be produced: |
- | Use this to test both your script | + | < |
+ | 671-477 occurs 3 times | ||
+ | 742-703 occurs 2 times | ||
+ | Out of 12 lines (9 with numeric values), there were a total of 5 lines with duplicate values | ||
+ | </ | ||
+ | |||
+ | =====Task 6: Find and display the max duplicates===== | ||
+ | |||
+ | From your filtered output in the previous task, write some logic that: | ||
+ | |||
+ | * Removes the " | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | * Put your output in a file called **task6.out** | ||
=====Submission===== | =====Submission===== | ||
Line 96: | Line 179: | ||
* All criteria indicated above | * All criteria indicated above | ||
- | * To signal completion, submit an archive containing the following | + | * To signal completion, submit an archive containing |
- | * botcheck script (call it **botcheck.sh**) | + | * Task 0: **task0.question** and **task0.response** |
- | * botkill script | + | * Task 1: **task1.txt** |
- | * a text file called (**at.txt**) containing syntax used to create/ | + | * Task 2: **task2.txt** |
- | * a listing of your crontab entries (**crontab.txt**), showing the correctly scheduled deployment of your script | + | |
- | * a copy of your configured bot's config file (**config.py**) | + | * Task 4: **task4.txt** |
- | * a text file containing the URL you downloaded your bot, along with any URLs you obtained modules/ | + | * Task 5: **task5.sh** and **task5.out** |
- | * Put all these files in a **tar** archive | + | * Task 6: **task6.sh** and **task6.out** |
- | * Compress it with max compression using **bzip2** | + | * Put all these files in a **tar** archive |
- | * Name the archive **ircbot.tar.bz2** | + | * Compress it with max compression using **gzip** |
- | * After you've recorded the crontab entry with your botcheck script, remove the entry from your crontab (so we don't end up with a bunch of phantom bots nobody cares about). | + | * The resulting |
- | * When you're done with this project, kill your bot. Do not leave it running. | + | |
- | + | ||
- | **NOTE:** If this activity fascinates you and you'd like to keep playing with your bot, do so using a different config/ | + | |
To submit this project to me using the **submit** tool, run the following command at your lab46 prompt: | To submit this project to me using the **submit** tool, run the following command at your lab46 prompt: | ||
<cli> | <cli> | ||
- | $ submit unix dataproc | + | $ submit unix dataproc |
Submitting unix project " | Submitting unix project " | ||
- | -> ircbot.tar.bz2(OK) | + | -> dataproc.tar.gz(OK) |
SUCCESSFULLY SUBMITTED | SUCCESSFULLY SUBMITTED |