我想创建一个shell脚本,用于在启动时为我的ubuntu 11.04打开一个新的浏览器链接,特别是ip,如192.168.1.25:87。
答案 0 :(得分:2)
我希望有帮助
#!/bin/bash
URL=$1
[[ -x $BROWSER ]] && exec "$BROWSER" "$URL"
path=$(which xdg-open || which gnome-open) && exec "$path" "$URL"
echo "Can't find browser"
答案 1 :(得分:0)
要在启动时在Ubuntu中运行脚本,请参阅以下链接。
http://upstart.ubuntu.com/getting-started.html
至于打开浏览器的脚本,有很多方法可以做到这一点,使用适合你的方法。将网址替换为您要打开的IP。
#/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