2012年10月20日土曜日

telnetスクリプト実行script

telnetスクリプト実行script

#!/bin/bash

#target_host=${1}
#target_user=${2}
#target_password=${3}
target_host="myhost"
target_user="user"
target_password="password"

MY_WAIT_1s="/bin/usleep 1000000"
MY_WAIT_2s="/bin/usleep 2000000"

(
/bin/echo "open ${target_host}"

${MY_WAIT_2s}
/bin/echo "${target_user}"

${MY_WAIT_1s}
/bin/echo "${target_password}"

${MY_WAIT_1s}
# /bin/echo "/bin/date >> /home/user/user.log"
/bin/echo "myprog -option"

${MY_WAIT_1s}
/bin/echo "y"

${MY_WAIT_2s}
/bin/echo "logout"

#) | telnet
) | telnet 2>&1 | tee -a /tmp/${0}.log 1>/dev/null

exit 0



2012年10月3日水曜日

bash 乱数

#!/bin/bash

ran=${RANDOM}
n=$((ran%100))

echo ${n}

exit ${n}