1

I am using chroot in a script, the purpose is to run a command, here is chroot syntax:

chroot [OPTION] NEWROOT [COMMAND [ARG]...]

The problem is the command I am running needs to take a variable defition, like this -

chroot   /myroot   FOO=BAR  my_cmd

But when I do this, I get error message bash : FOO=BAR, no such file or directory, looks like the first position must be command.

Is there a workaround of this?

2 Answers 2

1

This seems to work:

$ sudo FOO=bar chroot /srv/Chroot/precise-i386/ env | grep FOO
FOO=bar
0

You can also use alias here . for example

alias foo= 'your command '

place this command in your bashrc with

gedit .bashrc

then do source .bashrc

do all these in your terminal .

some one edit my post to put it in format because I'm doing this from my mobile .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .