我对linux命令很陌生。我使用Mac山狮作为我的操作系统和eclipse来编译我的java程序。
问题是,我试图在eclipse上以根用户的身份运行/编译/调试我的java应用程序。
遵循rednammoc在“How do I run my application as superuser from Eclipse?”中的步骤/答案
这个步骤要求我编写一个可执行脚本,让jre以根用户的身份运行,但是在脚本中有一部分使用命令gksu,我假设gksu命令只能在linux平台上使用,而不是在Mac平台上使用。当我运行我的程序时,它会显示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发布于 2013-12-04 14:44:20
有什么命令可以用来替换gksu吗?
osascript -e 'on run argv' \
-e 'do shell script (item 1 of argv) with administrator privileges' \
-e 'end run' \
"$jre $args"发布于 2015-05-06 01:43:40
嗯,我刚在http://pastebin.com/dhbU57uE发现这个还没试过呢!
#!/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"https://stackoverflow.com/questions/20378162
复制相似问题