【问题标题】:How to create a shell script for open browser with particular ip ?如何为具有特定 ip 的打开浏览器创建 shell 脚本?
【发布时间】:2014-05-07 09:26:17
【问题描述】:

我想创建一个 shell 脚本,用于在我的 ubuntu 11.04 启动时打开一个具有特定 ip 的新浏览器链接,例如 192.168.1.25:87。

【问题讨论】:

    标签: bash shell ubuntu


    【解决方案1】:

    希望对您有所帮助

    Clean way to launch the web browser from shell script?

    #!/bin/bash
    URL=$1
    [[ -x $BROWSER ]] && exec "$BROWSER" "$URL"
    path=$(which xdg-open || which gnome-open) && exec "$path" "$URL"
    echo "Can't find browser"
    

    【讨论】:

      【解决方案2】:

      要在启动时在 Ubuntu 中运行脚本,请参阅以下链接。

      http://upstart.ubuntu.com/getting-started.html

      至于打开浏览器的脚本有很多方法可以做到这一点,请使用适合您的一种。用你要打开的IP替换url。

      #/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
      

      【讨论】:

      • 在启动时不起作用,只在shell的直接执行中起作用
      • 是的,它的工作方式类似于将文本写入文件的任务,但在启动时打开浏览器任务不起作用。下面给出了我的 /etc/rc.local 代码 echo "iam working ok" >> /home /eyenet/Desktop/foo/mydoc & if which xdg-open > /dev/null;然后 xdg-open 'wwww.google.com' elif which gnome-open > /dev/null;然后 gnome-open 'wwww.google.com' fi
      • 当计算机启动时,它会运行一些启动脚本,但这是在用户登录到 X11 会话之前。也许你应该把它挂在你的个人 X11 会话启动中,而不是系统的启动脚本中。
      • 如何挂钩到个人 x11 会话启动?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多