Reputation: 3725
It worked.
#!/usr/bin/env bash
set -x
docker exec -it pure-ftpd ftp localhost
printenv
It failed, because of "the input device is not a TTY".
#!/usr/bin/env bash
set -x
{
echo "docker exec -it pure-ftpd ftp localhost"
} | {
bash
printenv
}
And environment variables of two scripts are same. Can someone tell me what is the difference? And SDKMAN use pipelines(2nd way) to run the script, when should not use pipelines?
Upvotes: 0
Views: 229
Reputation: 141483
Can someone tell me what is the difference?
The difference is the input to docker exec
.
docker exec ... - input is your keyboard
and:
{
echo docker exec ... - your keyboard is ignored, echo does not read from stdin
} | {
bash - The input comes _only_ from echo, which is captured by bash.
}
Because you requested an interactive TTY -ti
and because there is no more input (let's say "your keyboard is ignored"), there is nothing for docker exec -ti
to do.
Upvotes: 1