LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Closed Thread
  Search this Thread
Old 05-30-2014, 09:01 AM   #1
floriantraun
LQ Newbie
 
Registered: May 2014
Posts: 3

Rep: Reputation: Disabled
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'
 
Old 05-30-2014, 02:12 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981Reputation: 1981
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.
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem running an Expect script within a Bash script mbeipi Programming 9 02-10-2018 06:00 AM
[SOLVED] Problem in exporting variable from bash script to expect script uk.engr Linux - Newbie 3 06-14-2012 02:57 AM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 09:56 AM
Bash script problem with ftp session exiting the script early edomingox Programming 5 02-23-2010 06:39 AM
[SOLVED] bash : getopts problem in bash script. angel115 Programming 2 03-02-2009 11:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration