reading input problem.

Reply

Join Date: Sep 2009
Posts: 4
Reputation: railmaster7 is an unknown quantity at this point 
Solved Threads: 0
railmaster7 railmaster7 is offline Offline
Newbie Poster

reading input problem.

 
0
  #1
20 Days Ago
The problem I'm having is that I want to read in whether the user wants to keep the spelling or change it, but the "read spelling" pulls from the 'line' and not from user input.

my assignment description is as follows.


Write a shell script that implements an interactive spell checker. The general format for invocation is:

wordspell file

where "wordspell" is the name of the executable file that contains your shell script, and "file" refers to the file to be checked word-by-word for spelling.

Your are encouraged to take advantage of the "ispell -l" command. It produces a list of misspelled words from standard input.
Specification:
wordspell reads "file" and checks it for spelling of the words it contains. wordspell is invoked interactively. For each word that is found to be incorrect, the invoker is asked for either:

* to insist on the spelling of the word.
* to provide a replacement spelling

If the invoker insists on the spelling of the word, then this word is added to wordspell's "memory". wordspell remembers words in the file "memory" in the invoker's home directory. Any further invocation of wordspell by the same invoker will consider the word to be correct.

Otherwise the invoker is prompted for a replacement spelling. As output, wordspell produces a 2-column-ed list of words, the left column lists incorrectly spelled words, the right column lists their replacement as given by the invoker. The list is produced after the invoker has answered to all incorrectly spelled words.

Shell Scripting Syntax (Toggle Plain Text)
  1. #! /bin/bash
  2.  
  3. touch memory
  4. touch tempword
  5. ispell -l < "$1" |
  6. while read line
  7. do
  8. echo "$line is mispelled. Press "'Enter'" to keep this spelling, or type a correction here:"
  9.  
  10. read spelling
  11.  
  12. if [$spelling = ""]; then
  13. echo $line >> memory
  14. else
  15. echo $spelling >> tempword
  16. fi
  17. done
  18.  
  19. paste memory tempword > allfile
  20. #echo $allfile

Any help would be appreciated. thanks!
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC