So I have a perl script which takes in 2 arguments.
- a directory leading to the '.txt' files I am interested in searching through
- a file that has words in it which I have converted to an array.
Perl file (perlstemmer.pl):
#!/usr/bin/perl
use strict;
use warnings;
open(ALLFILES,"/Users/mymacbook/saver/rssFolders/txt") or die "Can't Open: $!\n";
open(TRIGGERFILE,"/Users/mymacbook/trigger.txt") or die "Can't Open: $!\n";
my $line=<>;
my %words;
my $i;
my @triggers =<TRIGGERFILE>;
while(<TRIGGERFILE>) #read each line into $_
{
chomp @triggers; # Remove newline from $_
push @triggers, $_; # add the line to @triggers
#/puts all txt from trigger.txt into the array @triggers. /
}
while($line ne "")
{
%words = split(//, $line);
}
foreach $i(@triggers)
{
if (exists $words{$i})
{
return 1;
}
$line= <>;
return 0;
}
So I this script will return a 1 if the file has a word from the array @triggers and a 0 if it does not....
Bash script organise.sh
Then the bash script reads in if it has a 1:
#!/bin/sh
DIR=$5
for a in `ls $DIR*`
do
b=`basename $a`
perlStemmer.pl $a >> tmp
$b = filter.pl tmp
if [$b == 1]; then
cp $a ../crimeStories/$b
echo "$a describes crime"
else
echo "$a does NOT describe crime"
fi
done;
exit 0;
-> So copy the file $a if it returned a 1. and print: that it does describe Else... if it returns a 0 say it doesn't describe crime and do nothing with it :-)
My problem
I'm getting a crazy terminal when I try running this:
>./organise.sh: line 8: perlStemmer.pl: command not found
./organise.sh: line 10: perlStemmer.pl: command not found
./organise.sh: line 11: [perlStemmer.pl: command not found
perlStemmer.pl does NOT describe crime
./organise.sh: line 8: perlStemmer.pl: command not found
./organise.sh: line 10: version.plist: command not found
./organise.sh: line 11: [version.plist: command not found
version.plist does NOT describe crime
./organise.sh: line 8: perlStemmer.pl: command not found
./organise.sh: line 10: Jennie:: command not found
./organise.sh: line 11: [Jennie:: command not found
Jennie: does NOT describe crime
./organise.sh: line 8: perlStemmer.pl: command not found
./organise.sh: line 10: Assignment: command not found
./organise.sh: line 11: [Assignment: command not found
Assignment does NOT describe crime
./organise.sh: line 8: perlStemmer.pl: command not found
./organise.sh: line 10: 1.doc: command not found
./organise.sh: line 11: [1.doc: command not found
1.doc does NOT describe crime
./organise.sh: line 8: perlStemmer.pl: command not found
./organise.sh: line 10: Document.pdf: command not found
./organise.sh: line 11: [Document.pdf: command not found
Document.pdf does NOT describe crime
./organise.sh: line 8: perlStemmer.pl: command not found
./organise.sh: line 10: Gers: command not found
./organise.sh: line 11: [Gers: command not found
Gers does NOT describe crime
./organise.sh: line 8: perlStemmer.pl: command not found
./organise.sh: line 10: polo's: command not found
./organise.sh: line 11: [polo's: command not found
polo's does NOT describe crime
./organise.sh: line 8: perlStemmer.pl: command not found
./organise.sh: line 10: contact: command not found
./organise.sh: line 11: [contact: command not found
contact does NOT describe crime
./organise.sh: line 8: perlStemmer.pl: command not found
perlStemmer does exist I have tried adding its full path to it but then the program only seems to search the folder where perlStemmer.pl is.
I can see that it seems to be splitting file names and folder names.
Anyone any idea what I'm doing wrong or what may be causing this in keep looping?
I'm also getting this:
This (the Directory node) gives a menu of major topics.
Typing "d" returns here, "q" exits, "?" lists all INFO commands, "h"
gives a primer for first-timers, "mEmacs<Return>" visits the Emacs topic,
etc.
In Emacs, you can click mouse button 2 on a menu item or cross reference
to select it.
--- PLEASE ADD DOCUMENTATION TO THIS TREE. (See INFO topic first.) ---
* Menu: The list of major topics begins on the next line.
Emacs
* Ada mode: (ada-mode). The GNU Emacs mode for editing Ada.
* Autotype: (autotype). Convenient features for text that you enter frequently
in Emacs.
* CC Mode: (ccmode). Emacs mode for editing C, C++, Objective-C,
Java, Pike, and IDL code.
* CL: (cl). Partial Common Lisp support for Emacs Lisp.
* Dired-X: (dired-x). Dired Extra Features.
* EUDC: (eudc). A client for directory servers (LDAP, PH)
* Ebrowse: (ebrowse). A C++ class browser for Emacs.
* Ediff: (ediff). A visual interface for comparing and merging programs.
* Emacs: (emacs). The extensible self-documenting text editor.
* Emacs FAQ: (efaq). Frequently Asked Questions about Emacs.
* Emacs MIME: (emacs-mime). The MIME de/composition library.
* Eshell: (eshell). A command shell implemented in Emacs Lisp.
* Forms: (forms). Emacs package for editing data bases
by filling in forms.
* Gnus: (gnus). The newsreader Gnus.
* IDLWAVE: (idlwave). Major mode and shell for IDL and WAVE/CL files.
* MH-E: (mh-e). Emacs interface to the MH mail system.
* Message: (message). Mail and news composition mode that goes with Gnus.
* PCL-CVS: (pcl-cvs). Emacs front-end to CVS.
* RefTeX: (reftex). Emacs support for LaTeX cross-references and citations.
* SC: (sc). Supercite lets you cite parts of messages you're
replying to, in flexible ways.
* Speedbar: (speedbar). File/Tag summarizing utility.
* VIP: (vip). An older VI-emulation for Emacs.
* VIPER: (viper). The newest Emacs VI-emulation mode.
(also, A VI Plan for Emacs Rescue
or the VI PERil.)
printing in the terminal!!