title: How to escape a Linux command which has all characters like single quote, double quote(',",`) in python?
body: <p>I have the following Linux command which gives metrics like CPU%, RAM%, and Hard disk percentage.</p>
  
  <pre><code>echo "CPU `LC_ALL=C top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print 100 - $1}'`% RAM `free -m | awk '/Mem:/ { printf("%3.1f%%", $3/$2*100) }'` HDD `df -h / | awk '/\// {print $(NF-1)}'`"
  </code></pre>
  
  <p>I want to store it in a variable as a string. But I'm not able to store due to the usage of `,",' in the Linux command. How can i make it work?</p>
  
  <p>Note: I'm storing this as a string in a variable because I want to check metrics like CPU%, RAM%, and Hard disk percentage by doing ssh to a server and executing the above command with the help of <a href="https://www.pythonforbeginners.com/code-snippets-source-code/ssh-connection-with-python" rel="nofollow noreferrer">pexpect/pxssh</a> library in python.</p>