Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in ..../includes/class_bbcode.php on line 2962

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
ONLINE/COMMAND-LINE DICTIONARY
Results 1 to 9 of 9

Thread: ONLINE/COMMAND-LINE DICTIONARY

  1. #1
    Guest

    ONLINE/COMMAND-LINE DICTIONARY

    Need a dictionary, but don't haveone in your system.

    Create the following script called "dict" (or name of your choice).It uses the lynx web browser (freelyavailable on the internet) togo out to dictionary.com and find the word your looking for.

    Code:
    #!/bin/csh -f
    
    set word=$1
    
    # lynx is a text-based browser 
    # available free on the web/net.
    lynx -cfg=/dev/null -dump "http://www.dictionary.com/cgi-bin/dict.pl?term=${word}" | more

  2. #2
    Associate
    Join Date
    Apr 2004
    Posts
    31
    thx man will try it out
    What is \'Real\' ? How do you define \'Real\' ?

    To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

  3. #3
    Member
    Join Date
    Apr 2004
    Location
    Pasadena, MD
    Posts
    106

    Ohhh

    Wow, I like it :shock:

  4. #4
    Cool idea!
    Of course, it made me want to write a bash version right away, here it is for those who don't have (t)csh installed:

    Code:
    #!/bin/bash
    lynx -dump "http://www.dictionary.com/cgi-bin/dict.pl?term=$1" | less
    It uses the 'less' pager instead of 'more', so you can scroll back up (ok, a lot of people probably have alias more="less" in their .bashrc, so to most people it probably won't matter a lot)
    For those who use a pager a lot, I'd recommend to check out 'most' - it definitely beats less or one of the i'm-a-textbrowser-but-also-a-pager apps.
    As you probably know, your pager is used to view man pages - here's an example of less versus most:
    less pager
    most pager
    As you can see, 'most' highlights keywords in man pages.
    You can set up your pager by modifying the $PAGER environment variable, so in your ~/.bashrc you can write:
    export PAGER=/usr/bin/most

    BTW I wonder why you specify "-cfg=/dev/null", this would break the script for those who have set up lynx to use a proxy, and *can't* browse the net without a proxy. Any specific reason for this?
    Oh, and what does the '-f' do in csh? I don't have a tcsh or csh man page apparently (weird...) and the --help isn't very helpful :-/

  5. #5
    I'm kinda bored right now, so I decided to make a "decent" version - yeah I know, almost no improvement or anything, but again, I did it out of pure boredom.

    Code:
    #!/bin/bash
    
    # BASH script created by Ludootje <ludootje at linux dot be>
    # written on&#58; 09/08/2004 &#40;Belgian date format&#41;
    # released under the GNU General Public License &#40;a.k.a. GPL&#41;
    # original csh version written by Mark "mcangeli" Angeli
    
    help&#40;&#41; &#123;
            echo "Usage&#58;"
            echo "  --help&#58; display this help."
            echo "  $0 word1 &#91;word2 word3 ... wordn&#93;"
            echo
            echo "You can use as many words as you like."
            echo "When you've read the explanation of the word, hit 'q' to move on to the next word."
            echo "To exit the program when it's running, hit ^C &#40;i.e. control+c&#41;, followed by 'q'."
    
            exit 0
    &#125;
    
    dict&#40;&#41; &#123;
           for i in "$@"; do
                   lynx -dump "http&#58;//www.dictionary.com/cgi-bin/dict.pl?term=$i" | less
           done
           exit 0
    &#125;
    
    case $1 in
       --help&#41; help
          ;;
       *&#41; for i in "$@"; do
             lynx -dump "http&#58;//www.dictionary.com/cgi-bin/dict.pl?term=$i" | less
        done
            exit 0
    esac
    #EOF
    Anyone an idea what's wrong with the dict() function? I wanted to use that after the *), but than it doesn't work... If I call the help() function after *), it works fine, so I must've misconstructed something in the dict()...
    Now I think about it, maybe I should pass arguments to it? But I have no idea how I could determine how many arguments (i.e. words in this case) are passed to the script, so I can't but them in variables. And dict($@) { ... } doesn't work.

  6. #6

    Re: ONLINE/COMMAND-LINE DICTIONARY

    Here's one for a thesaurus.

    Code:
    #!/bin/bash
    lynx -dump "http&#58;//www.m-w.com/cgi-bin/thesaurus?book=Thesaurus&va=$1" | less

  7. #7
    Advisor
    Join Date
    Apr 2004
    Location
    orlando
    Posts
    608
    Quote Originally Posted by Ludootje";p="2296
    I'm kinda bored right now, so I decided to make a "decent" version - yeah I know, almost no improvement or anything, but again, I did it out of pure boredom.

    Code:
    #!/bin/bash
    
    # BASH script created by Ludootje <ludootje at linux dot be>
    # written on&#58; 09/08/2004 &#40;Belgian date format&#41;
    # released under the GNU General Public License &#40;a.k.a. GPL&#41;
    # original csh version written by Mark "mcangeli" Angeli
    
    help&#40;&#41; &#123;
            echo "Usage&#58;"
            echo "  --help&#58; display this help."
            echo "  $0 word1 &#91;word2 word3 ... wordn&#93;"
            echo
            echo "You can use as many words as you like."
            echo "When you've read the explanation of the word, hit 'q' to move on to the next word."
            echo "To exit the program when it's running, hit ^C &#40;i.e. control+c&#41;, followed by 'q'."
    
            exit 0
    &#125;
    
    dict&#40;&#41; &#123;
           for i in "$@"; do
                   lynx -dump "http&#58;//www.dictionary.com/cgi-bin/dict.pl?term=$i" | less
           done
           exit 0
    &#125;
    
    case $1 in
       --help&#41; help
          ;;
       *&#41; for i in "$@"; do
             lynx -dump "http&#58;//www.dictionary.com/cgi-bin/dict.pl?term=$i" | less
        done
            exit 0
    esac
    #EOF
    Anyone an idea what's wrong with the dict() function? I wanted to use that after the *), but than it doesn't work... If I call the help() function after *), it works fine, so I must've misconstructed something in the dict()...
    Now I think about it, maybe I should pass arguments to it? But I have no idea how I could determine how many arguments (i.e. words in this case) are passed to the script, so I can't but them in variables. And dict($@) { ... } doesn't work.
    try

    Code:
    for i in $*
    instead of

    Code:
    for i in $@

  8. #8
    Newbie
    Join Date
    Nov 2004
    Location
    &#304;stanbul
    Posts
    3

    Re: ONLINE/COMMAND-LINE DICTIONARY

    I've just written a Q&D dictionary lookup script takes reference.com as base. Features:
    - Have both thesaurus and dictionary support
    - Omiting trailing (advertisement and unrequired) lines support
    Code:
    #!/bin/sh
    
    # dict.sh      &#58; Simple command line dictionary.
    # Requirements &#58; Internet connection to dictionary.com, lynx.
    # Written by   &#58; Volkan YAZICI &#40;a.k.a. `knt'&#41; <v0lkany'at'yah*oo~com>
    # License      &#58; GNU GPL &#40;General Public License&#41;
    
    
    # &#123;&#123;&#123; Variables
    LYNX="/usr/bin/lynx"
    FILE_TMP=`mktemp`
    URL_DICT="http&#58;//dictionary.reference.com/search?q="
    URL_THES="http&#58;//thesaurus.reference.com/search?q="
    # &#125;&#125;&#125;
    
    # &#123;&#123;&#123; help&#40;&#41;
    help&#40;&#41; &#123;
        echo "Usage&#58; $0 <-dict|-thes> <word> &#91;<word2> <word3> ...&#93;"
        exit 0
    &#125;
    # &#125;&#125;&#125;
    
    # &#123;&#123;&#123; Check execution parameters
    until &#91; -z "$1" &#93;
    do
        case $1 in
            "-dict"&#41;
                URL=$URL_DICT
                ;; 
    
            "-thes"&#41;
                URL=$URL_THES
                ;;
    
            *&#41;
                WORD=" $1"
                ;;
        esac
        shift
    done
    # &#125;&#125;&#125;
    
    # Remove trailing space at the start of the words sentence
    WORD="`echo $WORD | sed 's/^ //g'`"
    
    # Did the user satisfy the requirements?
    &#91;&#91; $&#123;#URL&#125; -eq 0  || $&#123;#WORD&#125; -eq 0 &#93;&#93; && help
    
    # Dump web page
    $LYNX -dump "$&#123;URL&#125;$&#123;WORD&#125;" 1> $FILE_TMP 2>&1
    
    # &#123;&#123;&#123; Chop trailing pieces
    LN_COUNT=`wc -l $FILE_TMP | cut -d' ' -f1`
    tail -n $&#91;$LN_COUNT - 12&#93; $FILE_TMP 1> $FILE_TMP.0
    > $FILE_TMP
    while read line
    do
        &#91; "`echo $line | grep ADVERTISEMENT`" &#93; && break
        echo $line >> $FILE_TMP
    done < $FILE_TMP.0
    # &#125;&#125;&#125;
    
    # Dump output
    rm -f $FILE_TMP.0
    cat $FILE_TMP && rm -f $FILE_TMP || echo "FILE_TMP&#58; $FILE_TMP"
    
    # vim&#58; set ai tabstop=4 fdm=marker&#58;

  9. #9
    Newbie
    Join Date
    Nov 2004
    Location
    &#304;stanbul
    Posts
    3
    Quote Originally Posted by knt
    I've just written a Q&D dictionary lookup script takes reference.com as base. Features:
    - Have both thesaurus and dictionary support
    - Omiting trailing (advertisement and unrequired) lines support
    Code:
    #!/bin/sh
    
    # dict.sh      &#58; Simple command line dictionary.
    # Requirements &#58; Internet connection to dictionary.com, lynx.
    # Written by   &#58; Volkan YAZICI &#40;a.k.a. `knt'&#41; <v0lkany'at'yah*oo~com>
    # License      &#58; GNU GPL &#40;General Public License&#41;
    
    
    # &#123;&#123;&#123; Variables
    LYNX="/usr/bin/lynx"
    FILE_TMP=`mktemp`
    URL_DICT="http&#58;//dictionary.reference.com/search?q="
    URL_THES="http&#58;//thesaurus.reference.com/search?q="
    # &#125;&#125;&#125;
    
    # &#123;&#123;&#123; help&#40;&#41;
    help&#40;&#41; &#123;
        echo "Usage&#58; $0 <-dict|-thes> <word> &#91;<word2> <word3> ...&#93;"
        exit 0
    &#125;
    # &#125;&#125;&#125;
    
    # &#123;&#123;&#123; Check execution parameters
    until &#91; -z "$1" &#93;
    do
        case $1 in
            "-dict"&#41;
                URL=$URL_DICT
                ;; 
    
            "-thes"&#41;
                URL=$URL_THES
                ;;
    
            *&#41;
                WORD=" $1"
                ;;
        esac
        shift
    done
    # &#125;&#125;&#125;
    
    # Remove trailing space at the start of the words sentence
    WORD="`echo $WORD | sed 's/^ //g'`"
    
    # Did the user satisfy the requirements?
    &#91;&#91; $&#123;#URL&#125; -eq 0  || $&#123;#WORD&#125; -eq 0 &#93;&#93; && help
    
    # Dump web page
    $LYNX -dump "$&#123;URL&#125;$&#123;WORD&#125;" 1> $FILE_TMP 2>&1
    
    # &#123;&#123;&#123; Chop trailing pieces
    LN_COUNT=`wc -l $FILE_TMP | cut -d' ' -f1`
    tail -n $&#91;$LN_COUNT - 12&#93; $FILE_TMP 1> $FILE_TMP.0
    > $FILE_TMP
    while read line
    do
        &#91; "`echo $line | grep ADVERTISEMENT`" &#93; && break
        echo $line >> $FILE_TMP
    done < $FILE_TMP.0
    # &#125;&#125;&#125;
    
    # Dump output
    rm -f $FILE_TMP.0
    cat $FILE_TMP && rm -f $FILE_TMP || echo "FILE_TMP&#58; $FILE_TMP"
    
    # vim&#58; set ai tabstop=4 fdm=marker&#58;
    in the above code, replace 'WORD=" $1" ' line with 'WORD="$WORD $1"'

Similar Threads

  1. command line help
    By jan1024188 in forum Windows - General Topics
    Replies: 1
    Last Post: 01-10-2007, 09:48 AM
  2. Do I need a command line?
    By Kauno-Uolevi in forum Linux - General Topics
    Replies: 18
    Last Post: 08-17-2003, 03:47 PM
  3. Games and Command Line Help PLease
    By AtomiC in forum Linux - Software, Applications & Programming
    Replies: 1
    Last Post: 08-15-2002, 03:35 AM
  4. Command line Printtool?
    By datamike in forum Linux - General Topics
    Replies: 2
    Last Post: 02-14-2002, 01:31 PM
  5. Using ftp from the command line.
    By chadm1967 in forum Linux - General Topics
    Replies: 5
    Last Post: 11-21-2001, 11:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •