LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Problem with a Bash Script (https://www.linuxquestions.org/questions/linux-software-2/problem-with-a-bash-script-4175506501/)

floriantraun 05-30-2014 08:01 AM

Problem with a Bash Script
 
Hi,

i've written a bash Script but I always get an error and I don't know why. The Script is supposed to recursivley Download a website an then parse all words out and put them in a word list.

Script:
Code:

#!/bin/bash
if [ "$1" -a "$2" ]
then
****echo ">> $(date +'%T') - Starting to downlad $1. This can take a long time..."
*
****#download websites recursively to ./temp/ directory, skip non-text files
****wget -r -l 2 --random-wait --user-agent='Mozilla/5.0' --quiet -R .jpg,.jpeg,.png,.gif,.bmp,.flv,.js,.avi,.wmv,.mp3,.zip,.css,.pdf,.iso,.tar.gz,.rar,.swf,.PNG,.GIF,.JPG,.JPEG,.BMP -P "./temp/" $1
*
****echo ">> $(date +'%T') - Finished downloading, creating wordlist..."
*
****#rescursively search for words that match out criteria in all files, 8+ chars, alpha
****page=`grep '' -R "./temp/" | sed -e :a -e 's/<[^>]*>//g;/</N;//ba' | tr " " "\n" | tr '[:upper:]' '[:lower:]' | sed -e '/[^a-zA-Z]/d' -e '/^.\{9,25\}$/!d' | sort -u`;
*
****echo "`date +"%T"` - Wordlist created!"
****echo ">> Fetched lines: $(echo "$page" | wc -l)"
*
****if [ -f '$2' ]
        then
********echo ">> File $2 already exists, merging files!"
********echo "$page" >> "$2";
********cat "$2" | sort -u -o "$2";
********echo ">> Wordlist merged with $2 and now has $(cat "$2" | wc -l) lines!";
****else
********echo "$page" > "$2"
********echo ">> Wordlist saved to $2!"
****fi
*
****#remove temporaray website directory
****rm -rf "./temp/"
else
****echo "Error: Parameter URL required!"
****echo "Example: $0 https://www.iana.org/domains/example/ ./wordlist.txt"
fi

Error:
Code:

./word_creator.sh: line 18: syntax error near unexpected token `then'
./word_creator.sh: line 18: `        then'


colucix 05-30-2014 01:12 PM

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate.


All times are GMT -5. The time now is 03:58 PM.