jexec and scripting with pipes/redirects

Normally one uses this kind of code to run a command within a named jail:

jexec jailname command parameters path

But it seems it's impossible to use any pipe and redirect as all of this fails:

jexec jailname cat /mysqldump.txt | mysql
jexec jailname mysql < /mysqldump.txt

It seems this has to do with the new shell that is created by a pipe and not proper handled withing the used execvp() of jexec. Has anyone an idea to solve the problem?
 
Well, this is expected behavior: piping and redirecting affects the current shell.

The trick is to spawn a shell inside the jail and use the -c argument. Here's a stupid example:

Code:
 # jexec somejail sh -c 'nonsense="Blah blah blah"; echo "$nonsense" | cat > /tmp/nonsense'
 # cat /path/to/somejail/tmp/nonsense
 Blah blah blah
 
Back
Top