Virtualization, Cloud, Infrastructure and all that stuff in-between

My ramblings on the stuff that holds it all together

Paste multi-line shell commands via SSH session

On occasion I have a bunch of commands to run inside a Linux VM over an SSH session from my Mac terminal (Zsh)

It’s tricky to get a variety of commands to reliably execute sequentially – some seem to trip over each other depending on how they handle i/o and this is a problem if you have something that is dependent on the previous command being completed.

Yes, I could copy the script to the server, chmod and run as a .sh bash script, use a proper CD toolchain etc. but I’m lazy and used to doing it this way from my Cisco days plus it also avoids leaving debug scripts on servers you’re working with 🙂

I’m sure there is a better way to do this, but I find this works really well.

SSH to your chosen Linux server

When you’re ready to go type an open brace “(”

Paste your command in

then close the brace “)”

and hit Enter.. and off you go all commands are executed sequentially and one by one.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: