944,208 Members | Top Members by Rank

Ad:
Nov 6th, 2009
0

reading input problem.

Expand Post »
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!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
railmaster7 is offline Offline
5 posts
since Sep 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Shell Scripting Forum Timeline: how to move files and check the completion.
Next Thread in Shell Scripting Forum Timeline: Problem printing date





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC