Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- source ~/.crawl.secret # Get $USERNAME and $PASSWORD
- # Example
- # $ cat .crawl.secret
- # USERNAME=myusername
- # PASSWORD=mypassword
- # name of tmux session
- export SESSION="crawl"
- # if session already running, attach it.
- tmux has-session -t $SESSION 2> /dev/null
- if [ $? -eq 0 ]; then
- echo "Session $SESSION already exists. Attaching."
- else
- # else create it, and detach it to work on it a bit
- tmux new-session -d -s $SESSION
- tmux new-window -t $SESSION:1 -k -n "crawl" "$SHELL"
- fi
- # if not already connected, connect and login
- if ! netstat -at |grep crawl.akrasiac.org |grep ESTABLISHED ; then
- tmux send-keys -t $SESSION:1 "ssh -i ~/.ssh/id_rsa.cao joshua@crawl.akrasiac.org" Enter
- sleep 1
- tmux send-keys -t $SESSION:1 "l"
- sleep 1
- tmux send-keys -t $SESSION:1 "$USERNAME" Enter
- sleep 1
- tmux send-keys -t $SESSION:1 "$PASSWORD" Enter
- tmux send-keys -t $SESSION:1 "p"
- fi
- tmux select-window -t $SESSION:1
- tmux attach -dt $SESSION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement