I am encountering a strange problem with my 64-bit Ubuntu – on the export command.
Basically, I have got a VM installation on Ubuntu on my Windows 7 system, and I am trying to pass commands from my Windows system to my VM installation using a custom (given by client) software.
So, on my VM, when I do:
export foo=bar
echo $foo
everything works as expected.
However, when I do the same through the custom software (which basically passes the Linux command as a string to the bash shell), I get:
export: command not found
I tried looking at the shell (using the custom software), using:
echo $SHELL > shell.txt
And I get /bin/bash which is expected and I still get the "export: command not found error".
How can I fix this?
exportis a Bash builtin,echois an executable in your$PATH. Soexportis interpreted by Bash as is, without spawning a new process.You need to get Bash to interpret your command, which you can pass as a string with the
-coption:ALSO:
Each invocation of
bash -cstarts with a fresh environment. So something like:will not work. The second invocation does not remember
foo.Instead, you need to chain commands separated by
;in a single invocation ofbash -c: