Tools and things that make my life easier - y'all might like them too
pipeit
Sends piped/redirected output to/from a file on a remote system
Syntax: pipeit [--verbose] system:path
| Argument | Description | Default |
| —— | ———– | ——- |
| dest
| Source/destination in form system:path
| This is a required argument and there is no default |
| Option | Description | Default |
| —— | ———– | ——- |
| -v
| Enable verbose debugging | Debugging is not enabled |
$ head -c10000 /dev/random > random
$ md5sum random
0bed19ac814a70a23065ac4842badc75 *random
$ ls -lh random
-rw-r--r-- 1 mrbruno mrbruno 9.8K Sep 15 15:44 random
$ pipeit ubuntu:/tmp/random < random
$ ssh -q ubuntu md5sum /tmp/random
0bed19ac814a70a23065ac4842badc75 /tmp/random
$
Note: Since /dev/random
produces random data, your mileage will vary - the checksum will be different but the amount of data is the same.
$ cat /dev/random | head -c10000 | pipeit vm1:/tmp/random
$ ssh vm1 md5sum /tmp/random
57adc4d45553de79f2ce5c6925b2ccdc /tmp/random
$ pipeit vm1:/tmp/random | md5sum
57adc4d45553de79f2ce5c6925b2ccdc -
$
ssh
is used under the covers and it works best if you have passwordless ssh working with an ssh keybase64
is used on both sides for transport.scp
be used?? but, alas, no:
$ date | scp -q -- - ubuntu:/dev/null # it won't read directly from stdin
scp: stat local "-": No such file or directory
$ scp -q <(date) ubuntu:/dev/null # you can't fake it out either - other tools are like this and don't plan for pipes even though they would work fine
scp: local "/dev/fd/63" is not a regular file
scp: failed to upload file /dev/fd/63 to /dev/null
$
I am often disappointed in Linux commands that don’t allow <(command)
for a file. Some of my older tools might be the same way but lately instead of making sure a file is a regular file, I just make sure it isn’t a directory - that way, I can support pipes. Ansible is a good example of this - I think I learned that ansible-playbook
doesn’t like a temporary playbook that I build on the fly in a pipe.
--become
option but abandoned it when I was facing strange errors I couldn’t correct. If someone has a good use case, I might return to it and get it to work. It should be possible!