我想运行我们在Mac OS X Mountain Lion上的Linux上编写的一些bash脚本。该脚本执行 #!/bin/bash
sudo su -l <username> << EOF
echo $HOME
#execute command that is only on the path of <username>
EOF
不,我运行脚本USER1,我在剧本尝试切换到user2
我坚持在代码执行写命令: Process sh = Runtime.getRuntime().exec("su -c [command]");
OutputStream os = sh.getOutputStream();
String filePath = Environment.getExternalStorageDirectory().getPath();
已经有some existing questions在这里询问有关以另一个用户身份运行命令的问题。但是,问题和答案集中在单个命令而不是一长串命令。 例如,请考虑下面的脚本: #!/bin/bash
set -e
root_command -p param1 # run as root
# these commands must be run as another user
comman
我有一个奇怪的权限问题。看起来,作为一个特定的用户登录,我有不同的权限,当我sudo苏该用户。 使用su成为quantka导致git的权限错误: sudo su quantka -c "git fetch"
conq: repository access denied.
fatal: The remote end hung up unexpectedly
但只是被登录为quantka工作: