tags:

views:

38

answers:

3

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?

+1  A: 

You could try

schroot -c name -u root "/bin/bash -c 'export A=3; export B=4'"

but this is the first time i've heard of schroot. And the exports look like they're useless...even running the double-quoted stuff directly from the command line, it seems the child shell doesn't want to affect the parent's environment.

cHao
I think the quoting would work out better for more complex commands if you did `schroot -c name -u root /bin/bash -c 'export A=3; export B=4'` instead.
Omnifarious
Possibly. But like i said, i've never seen schroot before. I wasn't sure whether the command had to be one string or what.
cHao
+1  A: 
schroot -c name -u root -- export A=3 && export B=4

Ensuring that /etc/schroot/schroot.conf has

run-exec-scripts=true
run-setup-scripts=true
DRL
A: 

I recommend:

schroot -c name -u root sh -c "export A=3 && export B=4"

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', ...

Jonathan Leffler