Guest User

Untitled

a guest
Aug 27th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function ab () {
  4. root=$1
  5. ser=$2
  6. return_Status=0
  7. R_FAIL=1
  8. restartCmd="/root/run.sh $ser"
  9. local USER=`whoami`
  10.  
  11. expect -c "
  12. log_user 0
  13. spawn su - root
  14. expect {
  15. timeout { send_user "nFailed to get password prompt after SSH as $USERn"; exit $R_FAIL }
  16. eof { send_user "nSSH failure for VMn"; exit $R_FAIL }
  17. "*assword:"
  18. {
  19. send "$rootr";
  20. expect {
  21. "]#"
  22. {
  23. send "$restartCmdr"
  24. expect {
  25. "*INFO*" {exit $SUCCESS}
  26. }
  27. }
  28. }
  29. }"
  30.  
  31. }
  32.  
  33. ab $1 "$@"
Add Comment
Please, Sign In to add comment