Guest User

Untitled

a guest
Oct 14th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. HOST=208.someip
  4. USER=root
  5. PASS=somepassword
  6.  
  7. # run command
  8. COMMAND="> /var/mail/root"
  9.  
  10. # do crazy expect stuff, store any output to a variable
  11. VAR=$(expect -c "
  12. spawn ssh $USER@$HOST
  13. expect \"*?assword:\"
  14. send \"$PASS\r\"
  15. expect \">\"
  16. send \"$COMMAND\r\"
  17. expect -re \"stuff\"
  18. send \"logout\"
  19. ")
  20.  
  21.  
  22. echo -e "\n\n======== OUTPUT ========"
  23. echo "$VAR"
  24. echo -e "======== OUTPUT ========\n\n"
Add Comment
Please, Sign In to add comment