Register
It is currently Tue Sep 16, 2014 9:28 am

Request for addition to very simple script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Sat Oct 11, 2008 10:10 am   

Joined: Sat Oct 11, 2008 9:46 am
Posts: 2
I was wondering if anyone could help me with adding on to this simple script I am using. I'm running it in Cygwin Bash shell on Windows XP.



Code:

while : ; do
   if lynx -dump http://URLhere.com |grep "\]0 [0-5]" ; then
      sndrec32.exe /play /embedding "C:\1alarm.wav" &
      sleep 11s
   fi
   date
done


This script obviously searches for a certain pattern of numbers on a web page and then activates a sound followed by an 11 second sleep if the numbers were present on the web page. The first number being searched must be 0 and is always a link, which is identified by the \] before the 0. Anyway, I want the script to be able to then figure out what link is three links BEFORE the number 0 and launch the URL of that link in a web browser of my choice.

For example - If it finds the pattern with 0 being link number 29 on the page, then I want link number 26's URL to be launched. I'm not an expert at this so I'm having trouble figuring out if this would be possible, but I have a strong feeling that it can be done and it's probably fairly simple to do.

Any answers would be a huge help. Thanks for taking the time to listen to my request. :)


Last edited by Mr M on Tue Dec 02, 2008 7:02 pm, edited 1 time in total.

Top
 Profile  
 PostPosted: Fri Nov 14, 2008 4:52 am   

Joined: Wed Sep 24, 2008 11:32 pm
Posts: 7
I am not quite sure of what you want to do because I never use "lynx --dump" and I am unluckily replying on a strange Windows machine.
But if you want to get the" three links before blah...", you could give "grep -B" a try. "man grep" will show details if you have "man" command on your machine.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 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:  


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