本文介绍了Mac OSX上的gksu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

im new to linux command ..
我使用Mac Osx Mountain Lion作为我的操作系统和eclipse来编译我的java程序..

im new toward linux command..Im using Mac Osx Mountain Lion as my operating system and eclipse to compile my java program..

问题是试图在eclipse上以root用户身份运行/编译/调试我的java应用程序。

The problem is that im trying to run/compile/debug my java application as root user on eclipse.

按照 as-superuser-from-eclipse>如何从Eclipse运行我的应用程序作为超级用户?

Following the step/answer from rednammoc in "How do I run my application as superuser from Eclipse? "

该步骤需要我写一个可执行脚本使我的jre以root用户身份运行,但是在脚本中有一部分使用命令gksu,我认为只有在linux平台上可用,而不是在Mac Osx平台上,当我运行我的程序时,它会显示gksu命令找到。所以问题是,

The step require me to write a executable script to make my jre to run as root user, however in the script there is a part where it uses the command gksu, which i assume only available on linux platform and not on Mac Osx platform and when i run my program, it show gksu command not found. So the question is,


  1. 我可以一些如何在Mac Osx上安装gksu?

  1. Can I some how install gksu on my Mac Osx?

还是有任何可以用来替换gksu的命令?

or is there any command that i can use to replace gksu?

是从链接复制的脚本,

#!/bin/bash
# file:  /usr/lib/jvm/java-6-openjdk/jre/bin/java
# descr: Starter for jdk. Runs jdk as root when
#        cmd-line-arg "--run-as-root" is specified.
#
jre="/usr/lib/jvm/java-6-openjdk/jre/bin/java.ori"
run_as_root=false
args=

# Filter command-line argument
for arg in "$@"
do
  case "$arg" in
  --run-as-root)  run_as_root=true
                  ;;
  *)              args="$args $arg"
                  ;;

  esac
done

# Remove leading whitespaces
args=$(echo $args | sed -e 's/^[ \t]*//')

if $run_as_root
then
  echo "WARNING: Running as root!"
  gksu "$jre $args"
else
  $jre $args
fi


推荐答案



osascript -e 'on run argv' \
          -e 'do shell script (item 1 of argv) with administrator privileges' \
          -e 'end run' \
          "$jre $args"

这篇关于Mac OSX上的gksu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-25 21:50