Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have Raspbian running on my Raspberry Pi, and I want to have a browser appear when it starts up. I am able to open a Midori window to the right page on start up, but my problem is that I receive a "cannot resolve host name" error, such like I would get if I was not connected to the internet. I followed the instructions listed on http://www.niteoweb.com/blog/raspberry-pi-boot-to-browser which were to enter in the command line:

$ sudo nano /etc/xdg/lxsession/LXDE/autostart

Comment everything and add the following lines:

@xset s off
@xset -dpms
@xset s noblank
@midori -e Fullscreen -a http://google.com

This process does open a Midori window on startup, but with the error mentioned above. If the page is refreshed then it works, but I want to be able to bring up a url without having a mouse or keyboard. I read that at the beginning of startup, internet may not be connected yet, so I created a bash script that delayed the process by twenty seconds before opening the Midori window. This did no work either, the same error persisted. I have also tried the process with chromium, to no avail as well.

share|improve this question

4 Answers 4

On my Pi I have a script that checks if I have an IP address before it does anything else:

IP.py

import socket
from time import sleep

def checknetwork():
    ip = False
    try:
        s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        s.connect(('google.com', 0))
        ip = s.getsockname()[0]
        s.close()
    except socket.error:
        return False
    else:
        return ip

def main():
    x = checknetwork()
    while x == False:
        print "Checking network ..."
        x = checknetwork()
        sleep(1)

This just tries to open a socket to some known address and fails until it can actually get a connection. Make it executable with:

chmod +x ip.py

You then need to add this to bootup by adding it to /etc/rc.local:

#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/usr/bin/python /directory/where/you/put/ip.py

exit 0

Hope that helps

share|improve this answer

I solved this problem by not entering my wireless network key but instead using the option of push button on Ap router. Connected straight away with no more problems even using wireless keyboard and mouse (via powered USB hub)

share|improve this answer
    
How does this relate to the OP's question? –  jasonwryan Oct 15 '13 at 0:11

Use ifconfig to detect ip address, and wait until you have an ip address (that is, $? == 0) (this assumes ipv4),

$ /sbin/ifconfig |grep "inet " |grep -v "127.0.0.1"
inet 10.2.3.15  netmask 255.255.255.0  broadcast 10.2.3.255
$ echo $?
0

that is,

#!/bin/bash
while [ 1 ]; do
    ip=`/sbin/ifconfig |grep -v "127.0.0.1" |grep "inet "`
    [[ $? == 0 ]] && break;
    echo "wait for ip"; sleep 1;
done
echo "got ip: $ip"
share|improve this answer

/etc/xdg/lxsession/LXDE/autostart:

@lxpanel --profile LXDE

@pcmanfm --desktop --profile LXDE

@xscreensaver -no-splash

@midori  --inactivity-reset=60 -e Fullscreen -a http://www.google.com

works for me

share|improve this answer

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.