escaping awk with remote ssh command and bash that is already escaped

ufk

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 ?

update

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.

ufk

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Escaping an exclamation mark in a ssh remote call to awk?

From Dev

Escaping an exclamation mark in a ssh remote call to awk?

From Dev

Regex for escaping single quotes which are not already escaped

From Dev

Escaping slashes in bash (awk)

From Dev

escaping in awk and bash script

From Dev

Checking the exit status of a ssh remote command in bash

From Dev

Passing a bash command to a remote host using ssh

From Dev

Bash command escaping quotes

From Dev

Escaping in wget bash command

From Dev

Bash command escaping quotes

From Dev

escaping quotes in putty remote command

From Dev

escaping quotes in putty remote command

From Dev

Escaping single quotes for ssh command

From Dev

From awk print a Specific coulumn's Value - passed to awk in a remote SSH - NOT WORKING. Attempted already "\$1"

From Dev

Command building & string escaping in Bash

From Dev

How to escape the single quote character in an ssh / remote bash command?

From Dev

bash doesn't load node on remote ssh command

From Dev

SSH + Sudo + Expect in Bash script: Run command with sudo in remote machine

From Dev

bash - Capture exit code from remote ssh command

From Dev

Escape awk command in ssh

From Dev

Escaping quotes and apostrophes through ssh command execution

From Dev

Escaping $ variable in sed over ssh command?

From Dev

Bash script - Piping command into another with escaped variables

From Dev

bash: bad flag in substitute command with escaped slashes

From Dev

Handling quoting and escaped spaces in Bash command arguments

From Dev

execute remote command on remote windows via linux while escaping quotes

From Dev

Escaping spaces in bash command line output

From Dev

Escaping single quotes in a bash script command

From Dev

AWK command in bash program

Related Related

  1. 1

    Escaping an exclamation mark in a ssh remote call to awk?

  2. 2

    Escaping an exclamation mark in a ssh remote call to awk?

  3. 3

    Regex for escaping single quotes which are not already escaped

  4. 4

    Escaping slashes in bash (awk)

  5. 5

    escaping in awk and bash script

  6. 6

    Checking the exit status of a ssh remote command in bash

  7. 7

    Passing a bash command to a remote host using ssh

  8. 8

    Bash command escaping quotes

  9. 9

    Escaping in wget bash command

  10. 10

    Bash command escaping quotes

  11. 11

    escaping quotes in putty remote command

  12. 12

    escaping quotes in putty remote command

  13. 13

    Escaping single quotes for ssh command

  14. 14

    From awk print a Specific coulumn's Value - passed to awk in a remote SSH - NOT WORKING. Attempted already "\$1"

  15. 15

    Command building & string escaping in Bash

  16. 16

    How to escape the single quote character in an ssh / remote bash command?

  17. 17

    bash doesn't load node on remote ssh command

  18. 18

    SSH + Sudo + Expect in Bash script: Run command with sudo in remote machine

  19. 19

    bash - Capture exit code from remote ssh command

  20. 20

    Escape awk command in ssh

  21. 21

    Escaping quotes and apostrophes through ssh command execution

  22. 22

    Escaping $ variable in sed over ssh command?

  23. 23

    Bash script - Piping command into another with escaped variables

  24. 24

    bash: bad flag in substitute command with escaped slashes

  25. 25

    Handling quoting and escaped spaces in Bash command arguments

  26. 26

    execute remote command on remote windows via linux while escaping quotes

  27. 27

    Escaping spaces in bash command line output

  28. 28

    Escaping single quotes in a bash script command

  29. 29

    AWK command in bash program

HotTag

Archive