I want to type a script into something like a heredoc and execute it without writing to a file first.
I use a Teensy3.2 microcontroller with an attached sdcard to automatically type out some repetitive tasks (like a USB macro keyboard).
Why? I have computers on which permanent file system changes/mass storage devices are not permitted and I have repetitive tasks that benefit from shell scripting.
But, I find this so very useful that I would like to load unmodified shell scripts onto the SDcard and execute them. The teensy can only type them out (no mass storage). Typing them out into a file requires them to be saved to the filesystem and execute permission granted before they can be executed and ultimately deleted.
I'm not real happy with this. It seems a bit hacky and I don't like automating file deletions with a "keyboard macro".
I've tried ssh << EOF etc... // but different computers require different passwords that aren't stored in the (unmodified) scripts and ssh does prompt for passwords and I am not permitted to change this configuration.
I've also tried exec << EOF etc... but I don't understand the behavior since it kills my shell when finished (which scares me).
Basically I want to:
Keyboard.print("exec << 'EOF'");
while (sdcardScriptFile.available()) {
Keyboard.write(sdcardScriptFile.read());
}
Keyboard.print("EOF");
Would it be better to just open a subshell and type out each line of the script? If so, would I just:
Keyboard.print("(");
while (sdcardScriptFile.available()) {
Keyboard.write(sdcardScriptFile.read());
}
Keyboard.print(")");
I would like to be able to add scripts to the SDcard and have them available to be typed and executed "on the fly" without making changes to the filesystem.