Bash – running remote command with arguments and shell using ssh

bashbashrc

I'm trying to execute a remote command using ssh.

I need the shell that executes the command to load .bashrc, so so far i've learned that i can use bash -lc for that. the problem is that it allows me to execute a command but ignore it's arguments

In general i want to run pm2 (Production process manager for Node.js)
with a list parameter to show me the available running tasks.

when I execute

ssh ufk@10.0.0.3 bash -lc pm2 list

or

ssh ufk@10.0.0.3 bash -lc "pm2 list"

I get the same results.
it executes the application as if i didn't provide any arguments at all.

here i provided the argument 'list' to pm2.

any ideas?

Best Answer

How about: ssh ufk@10.0.0.3 "bash -lc 'pm2 list'"

Related Question