Trying to run a piped command:
fly ssh console -C "cat /var/log/nginx/access.log | wc -l"
and it fails with
cat: invalid option -- 'l'
Try 'cat --help' for more information.
Error: ssh shell: Process exited with status 1
I know I can simplify the command in this case to something like this and avoid the pipe:
fly ssh console -C "wc -l /var/log/nginx/access.log"
But my bigger question is whether there’s a problem using piped commands in
-C command strings.
Thanks for any help!
Hi @eyepulp, the command that you specify with
-C is not run through a shell, which would interpret the pipe. In this case, you’re seeing the SSH server in your app running
cat with the literal arguments
If your app image does contain a shell, then you can invoke it explicitly. E.g., if you have a standard
fly ssh console -C 'sh -c "cat /var/log/nginx/access.log | wc -l"'
(It’s certainly not pretty! However, some minimal app images might not contain a shell, so this behavior allows
fly ssh console -C to work with them too.)
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.