This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
user:cforman:portfolio:project2 [2011/10/20 19:03] – created cforman | user:cforman:portfolio:project2 [2011/10/25 19:40] (current) – [References] cforman | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ======Project: | ||
+ | A project for Unix/Linux Programing by Corey Forman during the Fall 2011. | ||
+ | |||
+ | This project was begun on October 4th and took a week to complete. | ||
+ | |||
+ | =====Objectives===== | ||
+ | Make my irc bot perform basic tasks such as say hello and tell how many people are on. The real project is making it do basic math. | ||
+ | |||
+ | =====Prerequisites===== | ||
+ | In order to successfully accomplish/ | ||
+ | |||
+ | | ||
+ | * experience in basic scripting | ||
+ | * experience in looping | ||
+ | * experience in if statements | ||
+ | * experience in killing programs helps | ||
+ | |||
+ | =====Background===== | ||
+ | State the idea or purpose of the project. What are you attempting to pursue? | ||
+ | |||
+ | Upon approval, you'll want to fill this section out with more detailed background information. DO NOT JUST PROVIDE A LINK. | ||
+ | |||
+ | Providing any links to original source material, such as from a project page, is a good idea. | ||
+ | |||
+ | You'll want to give a general overview of what is going to be accomplished (for example, if your project is about installing a web server, do a little write-up on web servers. What is it, why do we need one, how does it work, etc.) | ||
+ | |||
+ | =====Scope===== | ||
+ | Give a general overview of your anticipated implementation of the project. Address any areas where you are making upfront assumptions or curtailing potential detail. State the focus you will be taking in implementation. | ||
+ | |||
+ | =====Attributes===== | ||
+ | State and justify the attributes you'd like to receive upon successful approval and completion of this project. | ||
+ | |||
+ | * commands : i am using commands | ||
+ | * files and directories : my bot sends information into a file + i am using files | ||
+ | * text processing : i am using the vi editor | ||
+ | * UNIX shell : i am working in the unix shell | ||
+ | * job control : my bot runs in the background | ||
+ | * scripting : i am scripting my bot | ||
+ | * regular expressions : im using regular expressions to grab entered commands so my bot can respond | ||
+ | |||
+ | =====Procedure===== | ||
+ | I sat down and thought of how it should work. | ||
+ | I started with just a loop that would activate when the command " | ||
+ | Next, I adjusted the loop to perform the math only when numbers are given. | ||
+ | After that i set up flags to moderate when the bot does anything within the loop. | ||
+ | finally I created a quit command for the math loop so it can be ended. | ||
+ | |||
+ | Frequently through out the project I got our teachers help to work out kinks during the process. | ||
+ | <cli> | ||
+ | #!/bin/bash -x | ||
+ | pkill ii 2>/ | ||
+ | BOT=" | ||
+ | #replace chan with #botchan2 | ||
+ | CHAN="# | ||
+ | SERV=" | ||
+ | ii -s $SERV -n $BOT & | ||
+ | PID=$$ | ||
+ | cd ~/irc/irc | ||
+ | echo "/join $CHAN" > in | ||
+ | cd " | ||
+ | CMD=" | ||
+ | while [ ! " | ||
+ | if [ " | ||
+ | echo " | ||
+ | fi | ||
+ | |||
+ | if [ " | ||
+ | echo " There are `who | wc -l` users on the system." | ||
+ | fi | ||
+ | |||
+ | if [ " | ||
+ | FLAG=1 | ||
+ | until [ " | ||
+ | |||
+ | if [ " | ||
+ | | ||
+ | | ||
+ | fi | ||
+ | if [ " | ||
+ | | ||
+ | elif [ "`echo $CMD | cut -c1`" -ge 0 ] && [ "`echo $CMD | cut -c1`" -le 9 ]; then | ||
+ | | ||
+ | elif [ "`echo $CMD | cut -c2`" -ge 0 ] && [ "`echo $CMD | cut -c2`" -le 9 ]; then | ||
+ | | ||
+ | else | ||
+ | | ||
+ | fi | ||
+ | | ||
+ | sleep 5 | ||
+ | done | ||
+ | fi | ||
+ | |||
+ | sleep 4 | ||
+ | CMD=" | ||
+ | done | ||
+ | echo "/ | ||
+ | exit | ||
+ | </ | ||
+ | |||
+ | =====Execution===== | ||
+ | |||
+ | <cli> | ||
+ | |||
+ | 15:33 -!- DOOMONU [~DOOMONU@lab46.corning-cc.edu] has joined #bottest | ||
+ | 15:34 < | ||
+ | 15:34 < | ||
+ | 15:34 < DOOMONU> Hello, gidron , Welcome to my MASTERS abode enjoy your stay <' | ||
+ | 15:34 < | ||
+ | 15:34 < | ||
+ | 15:34 < DOOMONU> The resault of 2+2 is 4 | ||
+ | 15:34 < | ||
+ | 15:34 < DOOMONU> The resault of quit math is | ||
+ | 15:34 < | ||
+ | 15:35 < | ||
+ | 15:35 -!- DOOMONU [~DOOMONU@lab46.corning-cc.edu] has quit [DOOMONU] | ||
+ | </ | ||
+ | |||
+ | My bot does math yahoo < | ||
+ | =====Reflection===== | ||
+ | During this process controlling the loops was highly difficult to keep it from spamming the channel. The flags we added worked wonderfully controlling the results that the bot spits out into the chat room. This is a very fun project and covers a large field of requirements for the course and comes highly recommended | ||
+ | =====References===== | ||
+ | In performing this project, the following resources were referenced: | ||
+ | |||
+ | * Matthew Haas |