我想做点什么:
schroot -c name -u root "export A=3 && export B=4"
Run Code Online (Sandbox Code Playgroud)
但我得到错误:
Failed to execute “export”: No such file or directory
Run Code Online (Sandbox Code Playgroud)
换句话说,我希望能够以编程方式在schroot环境中执行shell命令.获得这种行为的正确方法是什么?
我建议:
schroot -c name -u root sh -c "export A=3 && export B=4"
Run Code Online (Sandbox Code Playgroud)
这将使用'-c'选项运行shell,告诉它(shell)将以下参数作为要执行的命令(脚本)读取.相同的技术适用于其他类似的命令:'su','nohup',...