Skip to content

Instantly share code, notes, and snippets.

@danielnorberg
Forked from dln/pssh-aliases.sh
Created May 24, 2011 09:06
Show Gist options
  • Save danielnorberg/988394 to your computer and use it in GitHub Desktop.
Save danielnorberg/988394 to your computer and use it in GitHub Desktop.
Create aliases for working with remote clusters.
#
# Dependencies: pssh, pdsh, cssh
#
# Under ~/.pssh/ I keep lists of hosts, one cluster per file, one hostname per line.
#
alias mssh='f() { hosts=$1; shift; for h in $(cat ~/.pssh/$hosts); do ssh $h $@ ; done }; f'
# auto-generate aliases for common host groups
for hostlist in $(ls ~/.pssh/); do
for cmd in ssh scp rsync slurp nuke; do
alias p$cmd-$hostlist="p$cmd -h ~/.pssh/$hostlist"
done
alias pdsh-$hostlist="pdsh -w \$(tr \\\\n , < ~/.pssh/$hostlist)"
alias cssh-$hostlist="cssh \$(tr \\\\n ' ' < ~/.pssh/$hostlist)"
alias csshX-$hostlist="csshX \$(tr \\\\n ' ' < ~/.pssh/$hostlist)"
alias mssh-$hostlist="mssh $hostlist"
done
#!/bin/bash
hostsfile=$(ls ~/.pssh/ | dmenu -fn 10x20)
[ -n "$hostsfile" ] && exec cssh $(cat ~/.pssh/$hostsfile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment