Is there a way to execute a multi-line shell script by piping it to the remote shell's standard input in fabric? Or must I always write it to the remote filesystem, then run it, then delete it? I like sending to stdin as it avoids the temporary file. If there's no fabric API (and it seems like there is not based on my research), presumably I can just use the ssh module directly. Basically I wish fabric.api.run was not limited to a 1-line command that gets passed to the shell as a command line argument, but instead would take a full multi-line script and write it to the remote shell's standard input.
To clarify I want the fabric equivalent of this command line:
ssh somehost /bin/sh < /tmp/test.sh
Except in python the script source coude wouldn't come from a file on the local filesystem, it would just be a multiline string in memory. Note that this is a single logical operation and there is no temporary file on the remote side, meaning unexpected failures and crashes don't leave orphan files. If there were such an option in fabric (which is what I'm asking about), there would not need to be a temporary file on either side and this would only require a single ssh operation.