Basically, just use "os.system(str)". For example:
import os
cmd = 'ls'
os.system(cmd)
However, when we need to be root, e.g., running "sudo apt-get update", troubles come out, since a UI application started in N800 menu gives you no chance to input a password for background command "sudo" (in fact, we don't have the default password for maemo neither).
One way of gaining root permission in XTerminal is simply run "sudo gainroot" after install "becomeroot" package. But it does not work in UI application because an application and the command line it starts run in different processes.
To solve the problem, we need to add a line to file "postinst.ex" in debian directry, and change its name into "postinst".
Line 4 is what we add. It makes the script "run-standalone.sh" which starts all applications run well without being asked any passwords even "sudo" executed.
case "$1" in
configure)
echo -e "\n"user ALL = NOPASSWD: /usr/bin/run-standalone.sh >> /etc/sudoers
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
Actually, whatever we want to be executed can be added into the file "postinst", and then it will run during installation. Problems that cannot be worked out by codes may be solved easily here, like modifying files as root, etc.
本文介绍了一种在不需要输入密码的情况下运行sudo命令的方法。通过修改deb安装包中的postinst文件,并加入特定命令,使得应用程序能够顺利执行sudo操作。

被折叠的 条评论
为什么被折叠?



