Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I keep my PC running at home. Sometimes, when I'm at work, my PC can't load the pages that I want to load. I have to ssh to it, and reboot/restart browser. It's really annoying and I'm trying to find an easier way to do this. I thought about getting a screenshot and somehow try to check if it looks like a 404 page that I took screenshot before. But that may use my system resources a bit much.

I tried to catch the title of the page with xdotool, but it fails.

Is there a way of detecting 404 pages? I'm using chromium-browser with Ubuntu. Those webpages are not accessible from my computer because of my internet connection/computer. The webpage is always on, but sometimes, because of connection problems, browser shows 404 with that tiny dinosaur. This is my xdotool code:

#!/usr/local/bin/xdotool
a=`xdotool search "http://a.com is not available - Chromium" | head -1`
if [[ $a ]]; then
    echo "yes"
else
    echo "nope"
fi
share|improve this question
    
"Those webpages are not accessible from my computer because of my internet connection/computer. " hmmm that makes not sense in relation to checking a website? Is it not enough to check your internet connection itself? For instance: "ifconfig" shows you if you have an IP addres. "sudo ethtool eth0" checks your cable for instance. –  Rinzwind May 9 at 20:29
    
Oh uh. I deleted my nonsense output messages and messed this one. In my original one, I have a ". –  user1652575 May 9 at 20:30
    
@Rinzwind But here's the problem: The internet can and 90% of the time comes back after I get a 404. So, when I check the internet connection, everything is cool. But after I got a 404, and when my connection comes back online, this algorithm fails. Sorry. I think I can't explain clearly. –  user1652575 May 9 at 20:32

1 Answer 1

How about wget?

Three examples: one to a not existing page, one to an existing page you are not allowed to download and one that works.

wget http://askubuntu.com/testfor404

--2014-05-09 22:06:20--  http://askubuntu.com/testfor404
Resolving askubuntu.com (askubuntu.com)... 198.252.206.24
Connecting to askubuntu.com (askubuntu.com)|198.252.206.24|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2014-05-09 22:06:21 ERROR 404: Not Found.

wget http://askubuntu.com/reputation

--2014-05-09 22:07:11--  http://askubuntu.com/reputation
Resolving askubuntu.com (askubuntu.com)... 198.252.206.24
Connecting to askubuntu.com (askubuntu.com)|198.252.206.24|:80... connected.
HTTP request sent, awaiting response... 403 Forbidden
2014-05-09 22:07:11 ERROR 403: Forbidden.

wget http://askubuntu.com

--2014-05-09 22:07:36--  http://askubuntu.com/
Resolving askubuntu.com (askubuntu.com)... 198.252.206.24
Connecting to askubuntu.com (askubuntu.com)|198.252.206.24|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 69629 (68K) [text/html]
Saving to: ‘index.html’

100%[======================================>] 69.629       257KB/s   in 0,3s   

2014-05-09 22:07:36 (257 KB/s) - ‘index.html’ saved [69629/69629]

That command could be expanded to show "true" or "false" in case the output shows "ERROR 404: Not Found".


The option --delete-after will delete the index.html after downloading it. --spider flag will check the page header/status without downloading.

share|improve this answer
    
Using the --spider flag will check the page status without downloading. –  dan08 May 9 at 20:13
    
But all those webpages are all accessible. I get 404 because of me/my computer/my internet connection. And browser stucks in 404 page because of it. I'm updating my question now. Thank you, but this does not solve my problem. –  user1652575 May 9 at 20:20
    
if you do not have an internet connection active all of these will show a 404 :) Even websites that are active. –  Rinzwind May 9 at 20:31
    
no, 404 is when you connect to the webserver but this hasn't the page requested. Is a server side message, and I really doubt it would appear if you have connection problems @user1652575. –  Braiam May 9 at 20:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.