Hello.
ssh [email protected] "bash -lc 'pm2 list | grep app | awk { print $3} '"
I need to run the command I pasted here. the problem is that i'm already escaping twice... the bash with "
and the pm2 with '
. how can i escape awk ?
i know that it will work if i escape it with awk '{ print $3 }' but the all command is already escaped twice... so .. what do i do ?
i created the following bash command:
PM2_APP_ID=`$REMOTE_SRV_SSH_COMMAND "bash -lc \"pm2 list | grep app | grep -v 'pm2 show' | awk '{ print \\\$4 }'\""`;
here i get the all pm2 list relevant line, it's like awk is never been executed.
thanks @dave_thompson_085 for your comment, that helped me resolve the issue.
i'm using the following command:
PM2_APP_ID=`$REMOTE_SRV_SSH_COMMAND "bash -lc 'pm2 list'" | grep app | grep -v 'pm2 show' | awk '{ print $4 }'`;
as you can see here i use pm2 list on remove server, and the rest i'm doing locally. no hassle with escaping things and it works properly.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments