Hacker News new | ask | show | jobs
by lanstin 1065 days ago
If I can't fix it in like 3 tries, I switch to my local shell script having the script to run on the remote end be in a HEREDOC and just scp it it over and then ssh exec it. Inside the HEREDOC, it's a sane environment.
2 comments

Copying over the commands to run also has another added benefit, you have quite good documentation of what was run and when. Also it allows one to easily run a failing thing again (in case output gets mangled in the executing script)
And idempotency is essential for shell scripts that alter state. Otherwise you have to keep track of where failures happened.
wrap it in base64 then cat it | ssh « base64 -d | bash »