Register
It is currently Sun Aug 31, 2014 2:23 am

website check


All times are UTC - 6 hours


Post new topic Reply to topic  [ 7 posts ] 
Author Message
 PostPosted: Mon Sep 03, 2012 1:52 pm   

Joined: Mon Sep 03, 2012 1:37 pm
Posts: 4
Hi guys,
I should write a bash script that:
1) read from a file (text file) some links (about 100 website links);
2) for each of these, it should search a "keyword" into web-page;
3) give me a feedback, if it found or not found the "keyword" into web-page. The feedback should says me in which links it found the "keyword".

The problem for me is:"How can I capture a link at time from the text file?"

Can anyone help me, please?
thank you


Top
 Profile  
 PostPosted: Mon Sep 03, 2012 3:19 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 535
hi,

GIYF


Top
 Profile  
 PostPosted: Mon Sep 03, 2012 3:31 pm   

Joined: Mon Sep 03, 2012 1:37 pm
Posts: 4
Thank Watael!

I can continue to write my script bash... :)


Top
 Profile  
 PostPosted: Wed Sep 12, 2012 4:07 pm   

Joined: Mon Sep 03, 2012 1:37 pm
Posts: 4
I can't to take a link at time from my file.

I should take a link at time, download that page, search in this page a "keyword" and:
if the keyword there's, move the downloaded page into another directory
if the keyword there isn't, delete the downloaded page.

How can I do that?

Best regards


Top
 Profile  
 PostPosted: Wed Sep 12, 2012 4:27 pm   
User avatar

Joined: Fri Jul 22, 2011 5:39 pm
Posts: 47
http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://www.tldp.org/LDP/Bash-Beginners- ... index.html
http://www.gnu.org/software/bash/manual ... index.html
http://www.grymoire.com/Unix/Sh.html
http://www.tldp.org/LDP/abs/html/
http://mywiki.wooledge.org/BashFAQ
http://mywiki.wooledge.org/BashPitfalls


Top
 Profile WWW  
 PostPosted: Thu Sep 13, 2012 2:39 am   

Joined: Mon Sep 03, 2012 1:37 pm
Posts: 4
ok.

In a WHILE loop, what's mean to do: "done < myfile" at the end?

For example:
Code:
#!/bin/sh
while f=`line`
do
  .. process f ..
done < myfile


Top
 Profile  
 PostPosted: Thu Sep 13, 2012 7:22 pm   
User avatar

Joined: Wed Jun 08, 2011 8:27 am
Posts: 189
Location: outer Shpongolia
Code:
#!/bin/bash

# WEBPAGE LINKS FILE PATH
links_file="website_links.txt"

# (OPTIONAL) KEYWORD TO LOOK FOR
keyword="potato"


if [[ ! -f $links_file ]]; then
    printf '« %s »: no such file found.\n' "$links_file" >&2
    exit 1
fi

while [[ ! $keyword ]]; then
    read -rp 'Enter a keyword to look for: ' keyword
done

while read -r; do
    if grep -qi "$keyword" < <(wget -qO- "$REPLY"); then
        printf 'Keyword found on: %s\n' "$REPLY"
    fi 
done < "$links_file"


conoscenza wrote:
In a WHILE loop, what's mean to do: "done < myfile" at the end?

done < myfile is equivalent to done 0< myfile.

There isn't any connection with the while loop.

It redirects the file descriptor 0, which is the standard input, to the file myfile,
so myfile becomes the standard input instead of your keyboard, then it reads from it.

0 is the standard input by convention. It just is an abstract indicator to work with.
Just remember it as being your keyboard.


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP