Ispell Script Run Errors


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Ispell Script Run Errors
# 1  
Old 04-06-2011
Ispell Script Run Errors

I am going to get straight to the point. I am writing a script that acts as a simple spell checker using ispell. This script makes a list of mispelled words and prompts the user if he or she would like to correct the word or type in there corrections. When I run the script it does not read the list line by line.

This is my code:
Code:
#!/bin/bash
# script that will spell check a file

#variables
corSpel=()
let count=1

#creating temp files
touch niuspelled
touch tempword

#inputting mispelled words and outputting to tempword
tempword=('ispell -l -p testfile < $1')

for i in ${tempword[@]};
do
read -p "$i is mispelled. Press "Enter" to keep this spelling, or type a correction here: " corIn
   if [["$corIn" = "" ]];
      then
         echo $i >> .niuspelled
   else
         corSpel[$count]=$corIn

   fi
count+=1
echo ""
done

#for loop to print the correct words
printf "MISPELLED: "
printf "CORRECTIONS: "
echo ""

let count=1
for i in ${tempword[*]}
do
   echo ${corSpel[$count]}
   count+=1
done

This is the output I get.
z1624194@turing:~/csci330$ ./z1624194.spell testfile
ispell is mispelled. Press Enter to keep this spelling, or type a correction here:
./z1624194.spell: line 18: [[: command not found
-l is mispelled. Press Enter to keep this spelling, or type a correction here:
./z1624194.spell: line 18: [[: command not found
-p is mispelled. Press Enter to keep this spelling, or type a correction here:
./z1624194.spell: line 18: [[: command not found
testfile is mispelled. Press Enter to keep this spelling, or type a correction here:
./z1624194.spell: line 18: [[: command not found
< is mispelled. Press Enter to keep this spelling, or type a correction here:
./z1624194.spell: line 18: [[: command not found
$1 is mispelled. Press Enter to keep this spelling, or type a correction here:
./z1624194.spell: line 18: [[: command not found
MISPELLED: CORRECTIONS:

I would appreciate any help. I know for some reason my for loop is not reading through my passed in array, but my array list seems fine. I'm confused. Smilie
# 2  
Old 04-06-2011
Question

should
Code:
   if [["$corIn" = "" ]];

be
Code:
   if [[ "$corIn" = "" ]];

note the space I inserted
# 3  
Old 04-06-2011
I think you meant this:
Code:
tempword=( $(ispell -l -p testfile < $1) )

# 4  
Old 04-06-2011
Quote:
Originally Posted by joeyg
should
Code:
   if [["$corIn" = "" ]];

be
Code:
   if [[ "$corIn" = "" ]];

note the space I inserted
I'm not home to do a quick correction on my code but what would be the difference and putting the spaces in?
# 5  
Old 04-06-2011
Spaces are important before and after the [ or [[ characters when evaluating in unix. And also the complement ] and ]] characters. Has to do with how unix interprets the characters; I recall reading somewhere that the [ is sort-of a command; thus needing a space to separate it from rest of line.
Thus, my suggestion to put the space there.
This User Gave Thanks to joeyg For This Post:
# 6  
Old 04-06-2011
Quote:
Originally Posted by vgersh99
I think you meant this:
Code:
tempword=( $(ispell -l -p testfile < $1) )

When I fix my code and try that, it gives me

z1624194@turing:~/csci330$ nano z1624194.spell
z1624194@turing:~/csci330$ ./z1624194.spell
./z1624194.spell: line 13: $1: ambiguous redirect
MISPELLED: CORRECTIONS:
z1624194@turing:~/csci330$

Should I redirect my output a different way? Perhaps, like this ispell -l < tempword?
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies

2. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

3. Shell Programming and Scripting

Errors when Run

Hello, So here is what i have head -3 $1 > "$HOME/tmp/interchange_hold" tail --lines=+4 $1 > "$HOME/tmp/no_int_file_hold" tail -2 $HOME/tmp/no_int_file_hold > "$HOME/tmp/end_hold" head --lines=-2 $HOME/tmp/no_int_file_hold > "$HOME/tmp/rawfile_hold" cp "$HOME/tmp/end_hold"... (2 Replies)
Discussion started by: blesjt02
2 Replies

4. Shell Programming and Scripting

how to run an already made script run against a list of ip addresses solaris 8 question

how to run an already developed script run against a list of ip addresses solaris 8 question. the script goes away and check traffic information, for example check_GE-VLANStats-P3 1.1.1.1 and returns the results ok. how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
Discussion started by: llcooljatt
26 Replies

5. AIX

My script didn't run every run every minute at cronjob

In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all. * * * * * script.sh When I run it manually, I can run it. Is that anything wrong with the above line? If I change it to something like below,... (4 Replies)
Discussion started by: ngaisteve1
4 Replies

6. SuSE

automate ispell

Hello!! Is posible to automate ispell?? I have a lot of misspelled text and I want to launch a script that runs ispell choosing for example the first option, all that automatically. Is possible?? Thanks :) (4 Replies)
Discussion started by: elblo
4 Replies

7. Shell Programming and Scripting

quick ispell help

Hi, I am trying to write a script that calls ispell (my linux version doesn't have aspell) on a file and runs from there. Pretty much looks like this at the beginning: #!/bin/bash # script that will spell check a file read -p "Enter a file name: " fileName ispell fileName I just... (3 Replies)
Discussion started by: negzero7
3 Replies

8. SuSE

ispell

I tried to install ispell on my suse linux 8.2 do do spell cheking for my webmail but I issue rpm -Uvh ispell-3.2.06-266.i586.rpm i get the following error message error: failed dependencies: libc.so.6(GLIBC_2.3) is needed by ispell-3.2.06-266 I also try to install... (1 Reply)
Discussion started by: hassan2
1 Replies
Login or Register to Ask a Question