-
-
Save uWayLu/c99d1b87cef17117e0feffa29b0f11b1 to your computer and use it in GitHub Desktop.
A shell script to login PTT via ssh automatically.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env expect | |
# Login into PTT via SSH. | |
# Combine crontab with this script so you don't forget to login PTT everyday. | |
# Usage: /bin/bash -c ${FILE_PATH_OF_THIS_SCRIPT} | |
# Example in crontab: | |
# ptt auto login, every day at 12:00 PM | |
# 0 12 * * * /bin/bash -c ${ABSOLUTE_FILE_PATH_OF_THIS_SCRIPT} | |
spawn ssh -oBatchMode=no -oStrictHostKeyChecking=no [email protected] | |
set BBS_ID [lindex $argv 0] | |
set BBS_PW [lindex $argv 1] | |
expect { | |
"請輸入代號" { send "$BBS_ID\r" ; exp_continue } | |
"請輸入您的密碼" { send "$BBS_PW\r" ; exp_continue } | |
"您想刪除其他重複登入的連線嗎" { send "N\r" ; exp_continue } | |
"您要刪除以上錯誤嘗試的記錄嗎" { send "N\r" ; exp_continue } | |
"密碼不對喔" { exit } | |
"裡沒有這個人啦" { exit } | |
"請勿頻繁登入以免造成系統過度負荷" { send "\r" ; exp_continue } | |
"請按任意鍵繼續" { send "\r" ; exp_continue } | |
"oodbye" { exit } | |
} | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment