I want to create a shell script for open a new browser link with particular ip like 192.168.1.25:87 at startup for my ubuntu 11.04.
Asked
Active
Viewed 1,483 times
2 Answers
2
I hope that helped
#!/bin/bash
URL=$1
[[ -x $BROWSER ]] && exec "$BROWSER" "$URL"
path=$(which xdg-open || which gnome-open) && exec "$path" "$URL"
echo "Can't find browser"

Community
- 1
- 1

Khachatur Danielyan
- 21
- 3
0
To run a script in Ubuntu at start up see the following link.
http://upstart.ubuntu.com/getting-started.html
As for the script to open a browser there are many ways of doing this, use the one that works for you. Replace the url with the IP that you want to open.
#/usr/bin/env bash
if [ -n $BROWSER ]; then
$BROWSER 'http://wwww.google.com'
elif which xdg-open > /dev/null; then
xdg-open 'http://wwww.google.com'
elif which gnome-open > /dev/null; then
gnome-open 'http://wwww.google.com'
# elif bla bla bla...
else
echo "Could not detect the web browser to use."
fi
-
not worked at startup,only in direct excution of shell – user3459140 Mar 28 '14 at 04:55
-
@user3459140 Look here http://stackoverflow.com/questions/8339555/how-to-run-a-script-at-the-start-up-of-ubuntu for execute at startup.Also look here http://askubuntu.com/questions/814/how-to-run-scripts-on-start-up – Jayesh Bhoi Mar 28 '14 at 05:00
-
yes,it is worked like text write task to a document but open browser task not worked at startup.MY /etc/rc.local code is given below echo "iam worked ok" >> /home/eyenet/Desktop/foo/mydoc & if which xdg-open > /dev/null; then xdg-open 'http://wwww.google.com' elif which gnome-open > /dev/null; then gnome-open 'http://wwww.google.com' fi – user3459140 Mar 28 '14 at 05:41
-
When the computer boots, it runs some startup scripts, but this is before there is a user logged in to an X11 session. Probably you should hook this into your personal X11 session startup, not the system's boot scripts. – tripleee Mar 28 '14 at 06:12
-
how to hook into personel x11 session startup? – user3459140 Mar 28 '14 at 11:24