1
0

thread.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #!/bin/bash
  2. # Author: yeho <lj2007331 AT gmail.com>
  3. # Blog: http://linuxeye.com
  4. # Default Parameters
  5. myIFS=":::"
  6. IP=$1P
  7. PORT=$2P
  8. USER=$3
  9. PASSWD=$4P
  10. CONFIG_FILE=$5
  11. SSHTIMEOUT=$6
  12. SCPTIMEOUT=$7
  13. BWLIMIT=$8
  14. while read eachline
  15. do
  16. [ -z "`echo $eachline | grep -E '^com|^file'`" ] && continue
  17. myKEYWORD=`echo $eachline | awk -F"$myIFS" '{ print $1 }'`
  18. myCONFIGLINE=`echo $eachline | awk -F"$myIFS" '{ print $2 }'`
  19. if [ "$myKEYWORD"x == "file"x ]; then
  20. SOURCEFILE=`echo $myCONFIGLINE | awk '{ print $1 }'`
  21. DESTDIR=`echo $myCONFIGLINE | awk '{ print $2 }'`
  22. DIRECTION=`echo $myCONFIGLINE | awk '{ print $3 }'`
  23. ./mscp.exp $IP $USER $PASSWD $PORT $SOURCEFILE $DESTDIR $DIRECTION $BWLIMIT $SCPTIMEOUT
  24. [ $? -ne 0 ] && echo -e "\033[31mSCP Try Out All Password Failed\033[0m\n"
  25. elif [ "$myKEYWORD"x == "com"x ]; then
  26. ./mssh.exp $IP $USER $PASSWD $PORT "${myCONFIGLINE}" $SSHTIMEOUT
  27. [ $? -ne 0 ] && echo -e "\033[31mSSH Try Out All Password Failed\033[0m\n"
  28. else
  29. echo "ERROR: configuration wrong! [$eachline] "
  30. echo " where KEYWORD should not be [$myKEYWORD], but 'com' or 'file'"
  31. echo " if you dont want to run it, you can comment it with '#'"
  32. echo ""
  33. exit
  34. fi
  35. done < $CONFIG_FILE
  36. exit 0