如何使用sudo在X $ C $或C 4运行脚本生成阶段里面呢? [英] How to use sudo inside of a Run Script build phase in Xcode 4?
问题描述
我需要使用一个运行脚本的脚本内执行一个命令使用sudo以x code 4建造阶段。然而,编译器会抱怨:
I need use execute a command inside of a script in a Run Script build phase in Xcode 4 using sudo. However, the compiler complains:
须藤:没有TTY present并没有指定任何askpass程序
sudo: no tty present and no askpass program specified
任何人有这个问题的一个聪明的解决方案?
Anyone have a clever solution for this problem?
推荐答案
解决方案之一是将sudo的密码,像下面的一个可执行的shell脚本:
One solution is to place the sudo password in an executable shell script like the following:
#!/bin/bash
echo thesudopassword
本shell脚本可以被称为password.sh
This shell script might be called password.sh
然后,设置环境变量SUDO_ASKPASS = password.sh
Then, setup the environment variable SUDO_ASKPASS=password.sh
在这个设置中,-A选项可以传递给须藤。此选项使用ASKPASS程序获得sudo的密码。该ASKPASS程序只需要编写到标准输出的密码。
Once this is setup, the -A option can be passed to sudo. This option uses the ASKPASS program to obtain the sudo password. The ASKPASS program need only write the password to stdout.
因此,例如,
sudo -A ditto -V /tmp/testserver.dst /
这显然是一个相当不安全的解决方案,但它确实工作。
This is obviously a rather insecure solution, but it does work.
这篇关于如何使用sudo在X $ C $或C 4运行脚本生成阶段里面呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!