当前位置:   article > 正文

Linux 无root权限自动登陆脚本_免root运行sh脚本

免root运行sh脚本

 tcl下载:

链接:https://pan.baidu.com/s/159vFkd4dkkIuuEHUP7zACg 
提取码:xw1j

expect下载:

链接:https://pan.baidu.com/s/1MdCPZUs0XhcMNBgmzFEbhg 
提取码:1xom

  1. cd /home/whop
  2. tar zxvf tcl8.4.19-src.tar.gz
  3. cd /home/whop//tcl8.4.19/unix
  4. ./configure --prefix=$HOME
  5. make && make install
  6. cd /home/whop
  7. tar zxvf expect5.45.tar.gz
  8. cd /home/whop/expect5.45
  9. ./configure --prefix=$HOME
  10. make && make install
  11. vi autologin.sh
  12. #!/bin/bash 
  13. while true ;do
  14. read -p "please input the ip:128,129,130: " variable
  15. case $variable in
  16. "128" )
  17. host="10.213.83.128"
  18. passwd="A13@xy111j"
  19. break
  20. ;;
  21. "129" )
  22. host="10.213.83.129"
  23. passwd="Azz13@xyj"
  24. break
  25. ;;
  26. "130" )
  27. host="10.213.83.130"
  28. passwd="Azz113@xyj"
  29. break
  30. ;;
  31. *)
  32. echo "input error,please try again"
  33. ;;
  34. esac
  35. done
  36. /home/whop/hkh/sh/login.sh sxsgin $host $passwd
  37. vi login.sh
  38. #! /home/whop/bin/expect
  39. #user第一个参数
  40. set user [lindex $argv 0]
  41. #host第二个参数
  42. set host [lindex $argv 1]
  43. set passwd [lindex $argv 2]
  44. #set passwd "7p!Gsk$"
  45. #cm第三个参数,也就是要执行的命令
  46. #set cm [lindex $argv 2]
  47. spawn ssh $user@$host
  48. expect {
  49. "*yes/no" {send "yes\r";exp_continue}
  50. "*assword:" {send "$passwd\r"}
  51. }
  52. interact
  53. vi ~/.bash_profile
  54. alias logto='sh /home/whop/hkh/sh/autologin.sh'
  55. source ~/.bash_profile
  56. # .bash_profile
  57. # Get the aliases and functions
  58. if [ -f ~/.bashrc ]; then
  59.         . ~/.bashrc
  60. fi
  61. # User specific environment and startup programs
  62. PATH=$PATH:$HOME/.local/bin:$HOME/bin
  63. export PATH
  64. export JAVA_HOME=/home/sxsgin/jdk1.8.0_221
  65. export JRE_HOME=${JAVA_HOME}/jre
  66. export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib:$CLASSPATH
  67. export JAVA_PATH=${JAVA_HOME}/bin:${JRE_HOME}/bin
  68. export PATH=$PATH:${JAVA_PATH}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/721776
推荐阅读
相关标签
  

闽ICP备14008679号