hayateasdf's blog

Unity,C#, javascript,C++,python,batなど

ftpユーザアクセス確認

user_list (user-name,password)

ftpuser ftpuser
user001 user001
user002 user002

check-ftp.sh

#!/bin/bash
start()
{
    local file_name="./user_list"
    local ip_addr="192.168.1.101" # アクセスしたいipアドレスを指定

    cat ${file_name} | while read line;
    do
        declare -a ary=(${line})
        echo "open ${ip_addr}" > tmp
        echo "user ${ary[0]} ${ary[1]}" >> tmp
        log="`ftp -n < ./tmp`"
        if [ "$log" == "" ]; then
            echo "${ary[0]}: success"
        else
            echo "${ary[0]}: ${log}" 
        fi
    done
    rm -f ./tmp
}
start