My super simple ip checking script

i have a small home network with a PC running arch that acts as a NAT router; in the near future i am planning on setting up VPN access on this arch box. i would assume that it is imperative to know the external IP address of the router in order to connect. my ISP is comcast (cable) and they seem to be rather active in changing my DHCP'd address i get from them (in the past 6 months i have had 3 different ones). so i wrote this bash script that runs in the background and monitors the IP of the external interface. its pretty self explanatory; the mails to "vtext.com" are so i can have it texted to me. pointers would be welcome. i am not particularly a programmer, much more just an admin. the awk stuff seems messy, like there should be an easier way to isolate strings than that.... but idk. i run it
#!/bin/bash
# IP CHECK 2.0 (file name/path: /etc/scripts/ipcheck)
# runs in the background and
# requires sleep, mailx & ifconfig
# assumes external interface named "eth0"
# current ip output file path - single-line file containing current address (needs to be writable)
OPATH="/var/ipcheck/currentip"
# Amount of seconds to wait between checks
WAITSECS=300 # 5 mins
# Read previous IP from specified $OPATH file, if it's there
if [ -f "$OPATH" ]; then
OLDIP=`cat $OPATH`;
fi
# Begin main program loop
while :
do
# retrieve new ip using ifconfig
NEWIP=`/sbin/ifconfig eth0 | awk 'BEGIN{FS="inet ";RS=" netmask"}/</{print $2}' | tr -d '\\n' | tr -d ' '`
# print whatever was awk'd and the current date/time to tty11
echo "========= $NEWIP -- `date`" >> /dev/tty11
# if a different NEW IP is detected AND it isn't a null value, then do the following:
# * write the new address out to the OPATH file, replacing the previous value
# * e-mail the new address to my phone via vtext.com
# * e-mail both the old and new addresses to my main e-mail account
# * reset the $OLDIP value as the new one
if [[ "$OLDIP" != "$NEWIP" && "$NEWIP" != "" ]]; then
echo $NEWIP > $OPATH
echo "======= New Address - Old IP: $OLDIP ---- New IP: $NEWIP" >> /dev/tty12
echo "New IP: $NEWIP" | /usr/bin/mailx [email protected]
echo "Old IP: $OLDIP" | /usr/bin/mailx -s "New IP: $NEWIP" [email protected]
OLDIP=$NEWIP
fi
# pause in between checks, then start again
sleep $WAITSECS
done

falconindy wrote:
Isola wrote:
Here's my IP checking script, modified for mailx
#!/bin/bash
curl ifconfig.me | read IP
[ "x$IP" == "x`tail -n1 /tmp/wanip`" ] && exit 0
echo New IP: $IP
echo -n Old IP:
cat /tmp/wanip
echo -n Number of times you had this IP before:
grep $IP /tmp/wanip | wc -l
} | mailx -s "New IP: $IP" [email protected] [email protected]
echo $IP >> /tmp/wanip
This can't possibly work as is... The assignment in the first line happens in a subshell. It's going to be blank in the rest of the script.
Okay I admit, I just wrote that without testing it
edit:
The 2nd line can be changed for this:
read IP < <(curl ifconfig.me) || exit $?
Or
IP=$(curl ifconfig.me) || exit $?
Last edited by Isola (2012-07-01 00:59:39)

Similar Messages

  • SAP Bundle Patches and Automatic Oracle parameter check script (note117165)

    After reading SAP note 1027012 on SAP Bundle Patches and SAP note 1171650 on the
    automatic Oracle parameter check script I have a simple question:
    Is it still necessary to manually check whether some patch is installed in order to determine
    exactly which event and fixcontrol to set?
    Or is the automatic Oracle parameter check script so sophisticated that it is fully
    sufficient to implement its recommendations, and you don't neet to manually
    check any more which SBP with which bugfixes has been installed?
    It would be great if SAP could confirm that the automatic parameter check is sufficient,
    but so far I haven't seen this statement explicitly. I believe this is mostly because it
    is so difficult (impossible?) to determine via SQL which patches have been applied.
    Regards,
    Mark

    >
    > Is it still necessary to manually check whether some patch is installed in order to determine
    > exactly which event and fixcontrol to set?
    Yes and No.
    until now, fixcontrol are dependent of CBO patches and those are "register" on the view v$system_fix_control. They can be "check" autmatically, so you get the "proper" recommendation for those.
    the parameter event depends on different situations, like some patches. But those patches are "normal" patches and it is not possible to check if they are installed from inside the DB with a simple script. For those, the check script will tell you to do it manually and will tell you which patch has to be check
    In addition, there are other parameters that have to be check "manually", like processes (where you get a "semiautomatic" check) or db_cache_size, where you should check if the size
    > It would be great if SAP could confirm that the automatic parameter check is sufficient,
    > but so far I haven't seen this statement explicitly. I believe this is mostly because it
    > is so difficult (impossible?) to determine via SQL which patches have been applied.
    The automatic parameter check is sufficient, meaning that you get all information, including the parameters that you have to check manually and some information for that check. Currently, it is not possible to automatize it 100%

  • Bash Server Ping Checking Script

    Posted this on my blog yesterday, but thought i'd share it here too.
    I had alot of fun writing this little ping testing utility. It works/looks best if you have a color enabled terminal.
    Could be easily modified to email you if the server failed. Anyway, just thought I'd share
    #!/bin/bash
    # Bash Server Ping Checking Script
    # 09-24-2009 Crouse
    # Pretty simple, add servers/ip's/Ln (line numbers) in the format shown in the two column examples.
    # Tested with over 50 servers, worked for what I needed, thought i'd share :) ~~Crouse.
    # Ideas --- ad another array for Headers. so Hn could print headers with bold/etc. Might be neat.
    declare -a Sn # Server Name
    declare -a Ip # IP address of server.
    declare -a Ln # Line number to display on in Row1.
    declare -a Sn2 # Server Name
    declare -a Ip2 # IP address of server.
    declare -a Ln2 # Line number to display on in Row2.
    ############################################################################### Server List Row 1
    Sn[1]="usalug.org"
    Ip[1]="67.15.6.98"
    Ln[1]="6"
    Sn[2]="archlinux.me"
    Ip[2]="208.92.232.122"
    Ln[2]="7"
    ############################################################################### Server List Row 2
    Sn2[1]="usalug.org"
    Ip2[1]="67.15.6.98"
    Ln2[1]="6"
    Sn2[2]="archlinux.me"
    Ip2[2]="208.92.232.122"
    Ln2[2]="7"
    tput civis # Hide the cursor
    maxcount=${#Sn[*]} #should report number of Servers listed in Sn variable
    maxcount2=${#Sn2[*]} #should report number of Servers listed in Sn2 varialbe
    clear
    #tput setf 2; #echo -e '\e[1;33m'
    echo " "
    tput setf 0;tput setb 2;
    echo " Bash Server Ping Checking Utility version 2.0 Crouse. "; #tput rmso;
    tput setf 7; tput setb 0; # List out servers now.
    for (( loop=1; $loop < $maxcount+1; loop++ ))
    do
    ( tput cup ${Ln[$loop]} 10; echo "${Sn[$loop]}"; tput rc)
    done
    for (( loop2=1; $loop2 < $maxcount2+1; loop2++ ))
    do
    ( tput cup ${Ln2[$loop2]} 50; echo "${Sn[$loop2]}"; tput rc)
    done
    # Set traps so when we exit the big loop stuff is normal again.
    gracefulexit () {
    tput cnorm;
    tput setb 0;
    echo "Stopping Application"
    tput setf 2;
    exit
    trap gracefulexit INT TERM EXIT
    # Begin big loop
    while true
    do
    #First Row
    for (( loop=1; $loop < $maxcount+1; loop++ ))
    do
    (tput sc ;tput setb 0; tput setf 0; tput cup 4 10 ;
    echo "........................................................................";tput rc)
    (tput sc ;tput setb 0; tput setf 6; tput cup 4 10 ;
    echo "Checking ${Sn[$loop]} at IP: ${Ip[$loop]}" ; tput rc)
    (tput sc ;tput setb 0; tput setf 0; tput cup ${Ln[$loop]} 1 ; echo "........." ; tput rc)
    (tput sc ;tput setb 0; tput setf 6; tput cup ${Ln[$loop]} 1 ; echo "TESTING" ; tput rc)
    count=$(ping -c 5 ${Ip[$loop]} | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
    (tput sc ;tput setb 0; tput setf 0; tput cup ${Ln[$loop]} 1 ; echo "........." ; tput rc)
    if [[ "$count" == [45] ]]; then
    (tput sc ;tput setf 0; tput setb 2;tput cup ${Ln[$loop]} 5 ; echo " OK " ; tput rc)
    else
    if [[ "$count" == [123] ]]; then
    (tput sc ;tput setf 0; tput setb 6; tput cup ${Ln[$loop]} 4 ; echo "ALERT" ; tput rc)
    else
    (tput sc ;tput setf 7; tput setb 4; tput cup ${Ln[$loop]} 2 ; echo "WARNING" ; tput rc)
    fi
    fi
    done
    #Second Row
    for (( loop2=1; $loop2 < $maxcount2+1; loop2++ ))
    do
    (tput sc ;tput setb 0; tput setf 0; tput cup 4 10 ;
    echo "........................................................................";tput rc)
    (tput sc ;tput setb 0; tput setf 6; tput cup 4 10 ;
    echo "Checking ${Sn2[$loop2]} at IP: ${Ip2[$loop2]}" ; tput rc)
    (tput sc ;tput setb 0; tput setf 0; tput cup ${Ln2[$loop2]} 41 ; echo "........." ; tput rc)
    (tput sc ;tput setb 0; tput setf 6; tput cup ${Ln2[$loop2]} 41 ; echo "TESTING" ; tput rc)
    count2=$(ping -c 5 ${Ip2[$loop2]} | grep 'received' | awk -F',' '{ print $2 }' | awk '{ print $1 }')
    (tput sc ;tput setb 0; tput setf 0; tput cup ${Ln2[$loop2]} 41 ; echo "........." ; tput rc)
    if [[ "$count2" == [45] ]]; then
    (tput sc ;tput setf 0; tput setb 2;tput cup ${Ln2[$loop2]} 45 ; echo " OK " ; tput rc)
    else
    if [[ "$count2" == [123] ]]; then
    (tput sc ;tput setf 0; tput setb 6; tput cup ${Ln2[$loop2]} 44 ; echo "ALERT" ; tput rc)
    else
    (tput sc ;tput setf 7; tput setb 4; tput cup ${Ln2[$loop2]} 42 ; echo "WARNING" ; tput rc)
    fi
    fi
    done
    done
    Last edited by crouse (2009-09-25 14:40:42)

    http://social.technet.microsoft.com/Forums/exchange/en-US/6b8d299d-eed9-4493-bd49-42399f478f93/exchange-2010-server-up-time-script-help-needed?forum=exchange2010

  • Simple credit check for service orders(TAD)

    hi
    we have configured simple credit check for ZOR and with delivery block. since TAD is order related billing even though credit limit exceeds they can bill the customer.Now I have to configure simple credit check for serive orders with item category TAD and it should give billing block.please give me the details on this.

    Hello Chait
    To release credit block from CRM GUI, please go to header status tab here is the button 'Credit Release'.
    To release credit block in WEBUI, please check the items block, in more functions you can find the 'release credit block' link.
    Best regards,
    Maggie

  • Simple credit check - value need to be blocked from particular sales order to be post in f.35

    Dear Expert,
    I have a case here to find, the client uses simple credit check , we have different order types ( Example 6 order types), out of which we want to restrict the value of one order type to be posted in f.35 i.e the value should not effect credit limit used or open sales order.
    Is there any standard procedure by which this can be done or do we have to use userexit.
    Also can i know in which screen do we have to keep the userexits so that the value of the order type will not have impact on the f.35 or crdit limit used.
    Regards
    Abhishek Ojha

    Sorry small correction to my initial post.
    Even though you removed the credit group for the respective sales order type still system update the values subject to if the respective item category the "field credit active" active.
    Removing the credit group to sales order type controls whether you want to perform the credit check or not. And your requirement is not to update the particular sales order document values in FD32  so the actual control is credit active field for that particular item category.
    Since you have mentioned that you don't want to update that particular sales order document values( assuming that you are taking about receivable only).
    Please note sales order determines the item category,  so do as below.
    De select( un check) the credit active field in the item category which is determined based on the sales order type for  which you don't want to update credit values.
    Please test and update here.So far I did not check this in my system.
    thanks,
    Srinu.

  • Probably super simple...ACL/VLANs

    I have a VLAN 6 that is dedicated to a Partner organization (they share our bandwidth and schedule conference rooms with our Exchange).
    Question is how do I configure ACLs to direct ALL traffic to and from Partner, exception of accessing our Outlook Web Access and DNS servers in VLAN 1, and our websites in VLAN 2 ?
    This is probably super simple but I keep ending up with traffic going where I don't want it to.  Thanks so much...
    (And if anything else seems wacky about this setup, blame the last IT guy)

    What is the platform you are using??? ASA, router??
    Thanks,
    Varun Rao
    Security Team,
    Cisco TAC

  • Super Simple Flash Game Tutorials?

    I'm looking for some super simple flash game tutorials that students can complete in about an hour.  I don't want a lot of actionscript, but some is necessary and that's fine.  Drop any links you may know of or any book titles.  I don't mind buying a book if it is what I'm looking for.  Flash CS5

    This is an old technique but it works great using php:
    http://www.flashkit.com/tutorials/Games/High-sco-Glen_Rho-657/index.php

  • How to use dreamweaver to check scripts.

    I am both new to scripting and in using dreamweaver, I n
    eed to be able to copy an asp code and paste in dreamweaver and c
    ontinue with it, can anyone please help me on how to do this? , I a
    m testing dream weaver cs4

    I don't understand your subject line, "How to use dreamweaver to check scripts".  Can you explain what you mean by this?
    >I need to be able to copy an asp code and paste in dreamweaver and
    >continue with it, can anyone please help me on how to do this?
    You just copy the code from one page and paste into another. If you are having problems, you need to be more specific about what is not working.

  • Health check script suggestions...

    I used the health check script from metalink and it gave me few suggestion regarding my replication environment. One of them is ...
    + SUGGESTION: One or more propagation processes contain rule sets.
    + If a Propagation process will unconditionally forward all incoming
    + messages to its destination queue, and no rule-based transformations are
    + performed by the Propagation process, you should consider removing
    + the rule set for the Propagation process via dbms_propagation_adm.alter_propagation.
    + This will improve Propagation performance.
    What is get from this is since i have same rule defined in propagation also as the one in capture, So suggestion from orcale is remove the propagation rule and let everything propagted through...anyhow since i want everything a capture process captures to be replicated on destenation.. so i removed the propagation rule. ..
    But now the replication has stoped performing after that.....
    can any one suggest me if my undersanding for above healthcheck suggestion is wrong then wht does it mean?
    Kapil

    Did you remove both the rule AND the rule set, or did you remove only the rule?
    If it was a positive rule set and you removed only the rule, you left an empty rule set as a positive rule set for the propagation. This will cause it to discard all messages.
    An empty positive rule set is not the same as no (null) positive rule set. A null rule set means "forward all messages, since there is not filter rule", but an empty rule set means "there is a rule: that no message will be forwarded".
    Ilidio.

  • Battery check script

    Hi all!  I'm sure this one has been done to death, but with.  It's a script to monitor a laptop battery and react accordingly.  I wrote this for use with FVWM, to send out warning notices using libnotify when the battery gets too low.  Since my laptop is quite old, the battery runs out quite quickly after getting to 25% capacity.  The script backgrounds itself on being run.  It starts when I begin an FVWM session, and I have FVWM kill the script when I logout.
    Being a script it's easy to tweak to your particular requirements.  The example below just warns, but it would be easy to have the script suspend or hibernate the system, or change the percentage charge at which the script performs different actions.  I hope it's useful.
    #!/bin/bash
    # battery check script
    # ====================
    # Designed to be run continuously while WM is running
    # Requires libnotify to be installed
    ICONPATH=/home/rob/.fvwm/icons/24x18
    BATDIR=/sys/class/power_supply/BAT0
    NOTIFYSEND=/usr/bin/notify-send
    if [ ! -x $NOTIFYSEND ]
    then
    exit 0
    fi
    # check every $CHECK seconds
    CHECK=60
    ( while true
    do
    BATSTATE=`cat ${BATDIR}/status`
    # Note valid BATSTATE values are: Charged, Charging, and Discharging
    if [ "$BATSTATE" = "Discharging" ]
    then
    REM_CAP=`cat ${BATDIR}/charge_now`
    FULL_CAP=`cat ${BATDIR}/charge_full`
    CHARGE=`echo $(( $REM_CAP * 100 / $FULL_CAP ))`
    if [ "$CHARGE" -lt "25" ]
    then
    $NOTIFYSEND -i $ICONPATH/battery_critical.png -u critical -t 30000 "battery critical" "Shutdown or connect power now"
    sleep $CHECK
    continue
    fi
    if [ "$CHARGE" -lt "30" ]
    then
    $NOTIFYSEND -i $ICONPATH/battery_low.png -u normal -t 20000 "battery low" "Connect power soon"
    fi
    sleep $CHECK
    elif [ "$BATSTATE" = "Charged" ]
    then
    $NOTIFYSEND -i $ICONPATH/battery_full.png -u normal -t 20000 "battery fully charged" "Disconnect from power"
    sleep $CHECK
    else
    sleep $CHECK
    fi
    done
    # end of file
    Edited 21/10/2011 to use /sys/class/power_supply/BAT0 instead of /proc/acpi/battery/BAT0
    Last edited by Painless (2011-10-21 12:48:05)

    I'm not exactly sure what you're trying to accomplish; your script seems to me to be prone to high cpu-useage loops. If all you want is a warning message if your battery is low when your adaptor is not plugged in, then you could try the following script.
    One caveat, I don't have a laptop and I don't know what the output of
    acpi -b
    looks like, so I don't know which field contains the battery charge info. In the script below, I'm guessing that it is field number 3, so if it is different than that, the script below is incorrect and will not work.
    If you don't understand what I am talking about, run
    acpi -b
    on your laptop, and post the output for me.
    #!/bin/bash
    trap "exit" SIGINT SIGTERM
    delay=60
    warning=50
    while :
    do
    adapter=$(acpi -a | grep on)
    b=$(acpi -b | cut -d ' ' -f 3)
    [[ -z "$adapter" && "$b" -lt "$warning" ]] &&
    notify-send "WARNING - LOW BATTERY" "Battery has ${b}% left."
    sleep $delay
    done
    Last edited by rockin turtle (2011-01-15 06:08:45)

  • DB Health Check Scripts

    Hi all,
    Oracle 9i, 10g, 11g
    Can you share me your "health check" scripts which you have used in your PROD database and is proven to help you in carrying out your desired tasks being a good DBA :)
    Does AWR be able to generate health check report?
    Thanks a lot,
    Kinz

    KinsaKaUy? wrote:
    Thanks sb,
    http://www.orafaq.com/wiki/Scripts
    Wow this one site is complete, But it will take years for me to read all these. And I dont know if this is for 8i, 9i, 10g, or 11g.
    Can you tell me which of these scripts will list the Top 10 most resource consumers queries? in terms (CPU,Memory,I/O).If you enable SQL_TRACE prior to launching AWR report, then you capture EVERY SQL statement to build the report.
    You could easily observe the answer to your question if you were only willing to actually did some lilttle work instead of asking to be spoon fed.

  • Pre-requisite checker script for EBS R12 and R12.1

    hi
    is it possible to make a pre-requisite checker script (in perl or shell) for EBS R12 and R12.1 in RHEL5 or sun OS??
    can anyone help / guide me to do so??
    rgrds

    I don't know about EBS R12, but apparently the Oracle Universal Installer can use options to just run the prerequisite checks without having to install the product.
    E.g. /runInstaller -prereqChecker or -executeSysPrereqs
    There is also a specific OTN forum available for installing E-Business suite:
    LCM: 11i Install/Upgrade

  • Check(Script) - Pageformat

    Hi friends,
    I need the pageformat to assign as exactly as to my Check script.Here,Im using only the check window as needed to print the check details same to my client bank cheque.So, as u aware, the height of the check size will be upto approx 8cm and my client are using the dot matrix serial print cheques(continuous one as rolling format).
    Just reply me the exact pageformat.
    ****I've tested with available std INCH4/4C/2 and scheck formats but got no results.
    Pls advise.
    thanks & regards
    sankar.

    Hi,
    Solution for this problem will solve by your client, ask cleary the what the pageformat they are using. and by trail and error basis set the window heights, and Format the line, Paragrah, characer format.
    Bye

  • Is there any upgrade checking script for PL upgrade

    Dear Experts,
    I know there are Pre-upgrade checking script to validate database integrity before an upgrade from 2005 to 2007.
    However, is there any such similar scripts for an upgrade from 2007 PL12 to PL13? (Inter PL upgrade) or can I use the same script for the same purpose?
    Much Thanks!
    Warmest Regards,
    Chinho

    Hi Gordon,
    Thank you for your reply. Is it true that within inter-patch upgrades, there are no database structure change?
    I asked this question because sometimes I get "DB is inconsistent" error after upgrade, and I don't know why?
    Much Thanks for your Advice thus far!
    Warmest Regards,
    Chinho

  • Simple Spell Checker

    Hey. I'm pretty new to Java, but have to try and create a very simple spell checker. At the moment I have three classes and an interface, and I am to write a fourth and final class:
    DictionaryLoader, whichprovidesastaticmethod+loadTheDictionary+which
    readsthewordsfromafileandreturnsthemasanarrayofstringsinalphabetical
    order.
    SpellChecker, which stores the array of strings and provides a method called
    check to search it. It also provides a zeroargument constructor, which calls
    DictionaryLoader.loadTheDictionary.
    ISpellChecker is an interface defining the check method of SpellChecker.
    SpellCheckResultisaclassusedby+SpellChecker+toreturnresults.A
    SpellCheckResultobjecthaspublicfieldsindicatingwhetherthewordwas
    correctlyspeltand,ifnot,whatwerethewordsimmediatelybeforeandafterit.Ifit
    wasbeforethefirstdictionaryentryorafterthelastonethenoneofthesefields
    mightbenull.
    SpellCheckerUIisaclasscontainingamainmethodwhichprovidestheuser
    interfacetothesystem.
    I have the code for all of these other than SpellChecker, which I have to write, except I have no clue what I'm supposed to do.
    Here is the code for the four parts I have the code for:
    DictionaryLoader:
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.util.Scanner;
    import java.util.Vector;
    public class DictionaryLoader {
         public static final String dictFileName="/usr/share/dict/words";
         public static String[] loadTheDictionary() {
              Scanner s;
              try {
                   s = new Scanner(new BufferedReader(new FileReader(dictFileName)));
              } catch (FileNotFoundException e) {
                   System.err.println("Standard dictionary file "+dictFileName+" missing");
                   return new String[0];
              Vector<String> dict = new Vector<String>();
              while (s.hasNext()) {
                   dict.add(s.next());
              return dict.toArray(new String[0]);
    }ISpellChecker:
    public interface ISpellChecker {
        /* check a word w and return a SpellCheckResult object containing
           the outcome */
         public SpellCheckResult check(String w);
    }SpellCheckResult:
    public class SpellCheckResult {
        public boolean correct; /* true if the word was found */
        public String before;/* if the word was not found then this field
                     * contains the dictionary word before it, or
                     * null if there isn't one, else undefined */
        public String after;/* if the word was not found then this field
                    * contains the dictionary word after it, or
                    * null if there isn't one, else undefined */
        public SpellCheckResult(boolean result, String before, String after) {
         this.correct = result;
         this.before = before;
         this.after = after;
    }SpellCheckerUI:
    import java.util.Scanner;
    public class SpellCheckerUI {
          * @param args
         public static void main(String[] args) {
              // TODO Auto-generated method stub
              ISpellChecker sc = new SpellChecker();
              Scanner s = new Scanner(System.in);
              System.out.println("\n\n******SIMPLE SPELL CHECKER******\n\nEnter a word you would like to check the spelling of.\nType 'quit' to exit the program.\n");
              while (true) {
                   System.out.print("Word to check: ");
                   String w = s.next();
                   if (w.equals("quit"))
                        break;
                   SpellCheckResult r = sc.check(w);
                   if (r.correct)
                        System.out.println(w+" correct");
                   else
                        System.out.print(w+" was not found. Nearest neighbour(s) ");
                        if (r.before != null)
                             System.out.print(r.before+" and ");
                        if (r.after != null)
                             System.out.println(r.after);
              System.out.println("Thank you for using this program. Goodbye\n\n");
    }And so far, for the SpellChecker I have:
    public class SpellChecker extends SpellCheckerUI implements ISpellChecker {
         public SpellChecker() {
              DictionaryLoader.loadTheDictionary();
         public SpellCheckResult check(String w) {
              return null;
         public static void main(String[] args){
    }I have no idea what code to write in the SpellChecker, so if anybody can lend a hand at all, it'd be so helpful. Thank you.

    tad2382 wrote:
    Finding the w is a little bit trickier than it seems at first. At first, it might seem that you'd want to iterate through every entry in the array...but that would be horribly inefficient. A binary search would be better: O(log(n)) runtime instead of O(n).Only with "exact matches". But the OP would also need to find "near matches": making an ordered array with a binary search worthless. A radix tree would be the way to go.
    [http://en.wikipedia.org/wiki/Radix_tree]
    So basically, you'd check the middle word in the array. If it's what you want return it. If it's greater (Strings implement the comparable interface, just make sure you're ignoring case), check the lower half of the array, otherwise check the upper half. Then you'd recurse and do this for the upper/lower half of the array (your recursive method would take the min & max and look at the middle element). Your base case would be that you're left with the min & max as neighboring elements in the array (and you haven't found the word)--then you have your before & after and you're all set. Just be careful you're not skipping any entries in the array with a 1 off error.
    That's the pseudocode - hopefully you can figure out the java behind it.... or just get it working in a way that is the most easiest to implement. And if need be, improve it.

Maybe you are looking for

  • Is it possible to use a smaller configuration

    Hi everybody, I am new to OpenSparc community. I want to make a project which is using OpenSparc core, but there is one thing that I want to make sure. It is about which FPGA to choose to implement the core. First of all I checked the website http://

  • Apple Mail produces illegal html

    We've had all kinds of problems with Mac-generated emails coming up blank for some recipients. Our service provider did a detailed analysis and discovered that the Apple mail application (version 2.1 - 752/752.2) generates illegal html!!!! Here is an

  • Help with SESSION.Auth.IsLoggedIn

    I have buttons my users click to access password protected areas of my site. My problem is that everything is working great until the session times out, then clicking the button with the code below, doesn't throw the login popup, but rather goes to t

  • Trying to buy music but error

    when trying to purchase music from the itunes store.. a notice comes up saying "could not purchase. an unknown error occurred (11111)." this has been happening for days and even after i updated my itunes.. please help!

  • InfoObject for date information

    Hi everybody, Is there an standard InfoObject in SAP for date info where I could derive the month, quarter, week of a date ? In general what I need is that a load from the  source system a date (YYYYMMDD) but I need to create report in quarterly or w