Visit Our UNIX and Linux User Community


Linux Script to check Active URL in Firefox


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux Script to check Active URL in Firefox
# 1  
Old 05-29-2012
Linux Script to check Active URL in Firefox

Hey guys,

currently I'm struggling with a little script to check an active URL in my running Firefox.

What I'm doing:
I'm running a low VPS with about 768mb RAM and Ubuntu on it. I only installed Fluxbox + Firefox to it in order to keep the resource consumption as low as possible. I think i had success in that point. Now i would like to check an opened URL in firefox which is browsing through several videos. Sometimes it hits an Error Page cause the video might not be found etc. I set up a crontab which reboots the VPS every 15mins. This is just temporary and causes my VPS to waste a lot of time in order to wait for a reboot. It will also reboot if there is no error. Now I would like to optimize this, to check the current opened URL in firefox. If it's maybe like this blabla.com/error.php or blabla.com/start.php. If it's the first one do a quick reboot, otherwise do nothing. The script will be added as cron to run every min or so.

If you could give me a little impact on how to solve this I would very much appreciate it. Is this possible, or do I need to switch to other programming languages?

Anyways, thanks for your help! Smilie
# 2  
Old 05-29-2012
Probably the most sensible way to do this would be a script inside firefox itself. Just an HTML file you store on your own computer and open up in another tab, which runs a bit of javascript. It could be pretty low-impact that way too.

Trying to control firefox from the outside OTOH is going to be a royal pain.
# 3  
Old 05-29-2012
Well, I don't think you are able to reboot Linux via jscript, do you? Smilie
# 4  
Old 05-29-2012
Quote:
Originally Posted by uniflow
Well, I don't think you are able to reboot Linux via jscript, do you? Smilie
You want to reboot the entire system? Not the browser? Oh...

Why reboot the entire system based on a failing browser? Might it be possible to check for outside connectivity with different things, like ping and such? Because controlling a browser from console is still a pain. Different worlds.
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 05-29-2012
Well, I might try to just do a crontab with killall firefox && firefox.
# 6  
Old 05-29-2012
Why not just refresh the page, even? I had a javascript to do that until you said you needed to reboot the whole computer and I deleted it Smilie
# 7  
Old 05-29-2012
'dest' should be the webpage you want to reset it to. /regex/ is a regular expression which matches the page it stalls at.

Code:
<html>
<body>
        <script type='text/javascript'>
                var dest="http://website/whatever.html";
                var rwindow=window.open();
                var t=1000 * 5 * 60; // 5 minutes in milliseconds

                function refresh()
                {
                        if(rwindow.location.match(/regex/))
                        {
                                rwindow.location=dest;
                        }

                        setTimeout("refresh()", t);
                }

                refresh();
        </script>
</body>
</html>

This User Gave Thanks to Corona688 For This Post:

Previous Thread | Next Thread
Test Your Knowledge in Computers #831
Difficulty: Easy
Asynchronous JavaScript and JSON (or AJAJ) refers to the same dynamic web page methodology as AJAX, but instead of JSON, XML is the data format.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check if the URL exists?

Hi, I need to check if the URL exists. Below is my OS: SunOS mymac1 Generic_148888-04 sun4v sparc SUNW,SPARC-Enterprise-T5220 I do not have the curl set in the profile nor am i aware about its path. But i have wget. Please help me with params for the same. Can you help me check if... (6 Replies)
Discussion started by: mohtashims
6 Replies

2. Shell Programming and Scripting

Help with Perl script that can check a URL and notifiy when changes occur

I'm a scripting newbie and I'm trying to learn. No better way than being assigned a project. So basically, I'm trying to come up with a script that can periodically check a URL and then notify when changes occur to the file. So what I'm thinking is that I need to devise a PERL script that... (3 Replies)
Discussion started by: adam1mc
3 Replies

3. Shell Programming and Scripting

Url Check for a keyword.

thanks (0 Replies)
Discussion started by: kata33
0 Replies

4. Shell Programming and Scripting

ksh to check url

I have a server that keeps going down (503 Service not available). Until we find out the problem I would like to setup a simple ksh script in cron that will query url and report the status code. This way we can get someone to restart the process. Does anyone know a simple command I can call... (5 Replies)
Discussion started by: oldman2
5 Replies

5. Shell Programming and Scripting

Script to check if Port is Active

is there a better way to check if a port is active on linux and sunos systems? this is currently what I'm using in my script: netstat -an | egrep -i "$PORT" i know this isn't the best way as there could be numbers in that output that has my port number in it but isn't necessarily a... (0 Replies)
Discussion started by: SkySmart
0 Replies

6. UNIX for Dummies Questions & Answers

ReDirecting a URL to another URL - Linux

Hello, I need to redirect an existing URL, how can i do that? There's a current web address to a GUI that I have to redirect to another webaddress. Does anyone know how to do this? This is on Unix boxes Linux. example: https://m45.testing.address.net/host.php make it so the... (3 Replies)
Discussion started by: SkySmart
3 Replies

7. UNIX Desktop Questions & Answers

Launching Firefox (2.0) with No Toolbars + URL?

I'm using Firefox 2.x on Gentoo Linux 2008. I am going to be making a change here at work so that I no longer use a mail client, but use our web mail system. It may not be ideal compared to running Thunderbird, but I need to learn the web app enough to train users on more advanced features. The... (2 Replies)
Discussion started by: deckard
2 Replies

8. Shell Programming and Scripting

Check URL with ksh

Hi everybody, I'm currently writing a ksh script which automates the entire startup of a large number of Tibco BusinessWorks domains, as well as all the deployed components running on it. My script is to be used after an infrastructure release, when the entire environement is down. It... (1 Reply)
Discussion started by: HexAnubis666
1 Replies

9. Shell Programming and Scripting

url calling and parameter passing to url in script

Hi all, I need to write a unix script in which need to call a url. Then need to pass parameters to that url. please help. Regards, gander_ss (1 Reply)
Discussion started by: gander_ss
1 Replies

10. UNIX for Advanced & Expert Users

url calling and parameter passing to url in script

Hi all, I need to write a unix script in which need to call a url. Then need to pass parameters to that url. please help. Regards, gander_ss (1 Reply)
Discussion started by: gander_ss
1 Replies

Featured Tech Videos