I'm writing a small software that must pass to bash one string. the problem is that bash can't handle characters ", ', `. I've do a bruteforce software force gpg (if i use only digits and letters, this work without problems), but when my software generate a string that contains one (or more) of these character, i receive some bash errors. then i need to escape every markquotes inside the string. so for example, if the software, generate the string a"bc'1, i need to pass this string to bash a\"bc\'1. but i don't know how to do.
this is the code
subprocess.call('gpg -d --output '+decripted+' --passphrase "'+password+'" '+target+' 2>/dev/null', shell=True)
Can i use sed? I don't know how to incorporate sed. I've also thinked to save the generated password to a file, and then read the string from file like this
cat fileWithPassword | gpg -d --output OUTPUT_FILE -- passphrase-fd 0 TARGET_FILE
i've noticed that in this way (from bash) works, but i think that is not really efficient save and read a file. is there any way to escape every markquote withoud save it on a file?