i want to do something like:
schroot -c name -u root "export A=3 && export B=4"
but I get the error:
Failed to execute “export”: No such file or directory
In other words, I want to be able to programmatically execute shell commands inside the schroot environment. What is the right way to get this behavior?
I recommend:
or better:
This runs the shell with the ‘-c’ option telling it (the shell) to read the following argument as the command (script) to be executed. The same technique works with other analogous commands: ‘su’, ‘nohup’, …
The
--option terminates the arguments toschrootand ensures that any options on the rest of the command line are passed to and interpreted by the shell, not byschroot. This was suggested by SR_ in a comment, and the man page forschrootalso suggests it should be used too (search for ‘Separator’). The GNUgetopt()function by default permutes arguments, which is not wanted here. The--prevents it from permuting the arguments after the--.