Artificial intelligent assistant

Correctly escaping quotation marks I have the following command: python -c 'import crypt; print(crypt.crypt("$Password", crypt.mksalt(crypt.METHOD_SHA512)))' Where `$Password` is a shell variable. How do I correctly expand it as a variable, and not have it treated as a literal?

Don't as that would be a code injection vulnerability and also avoid passing passwords in arguments to commands, as they then become public by showing in the output of `ps` and they are sometimes logged in some audit logs.

Using environment variables is usually better:


PASSWORD="$Password" python3 -c 'import os, crypt
print(crypt.crypt(os.getenv("PASSWORD"), crypt.mksalt(crypt.METHOD_SHA512)))'


(here using the `VAR=value cmd` syntax as opposed to `export VAR` so the environment variable is passed only to that one command invocation).

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 651b1549192a590d6d6edaa5edcc6223