0

I am trying to send mail from a remote computer(Linux) over SSH using paramiko using the mail command. The exact command is

stdin,stdout,stderr=ssh_client.exec_command("echo "$email_body">email.txt")`

I get a invalid syntax error at the $. What's wrong here?

MisterMiyagi
  • 44,374
  • 10
  • 104
  • 119
Kevin
  • 83
  • 4

1 Answers1

0

You are using the double quote " as your string delimiter so you can't have it also inside your string because that will end the string in the wrong place. You can either escape the inner quotes like this \" or use single quotes inside your string.

So this:

"echo \"$email_body\">email.txt"

Or this:

"echo '$email_body'>email.txt"
Rob Kwasowski
  • 2,690
  • 3
  • 13
  • 32
  • These are shell commands to be executed on the remote computer, so i can't make any changes to them. Using """ """ (tripple ") works. – Kevin Jan 21 '20 at 11:30