Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #!/bin/bash
  2. _hostFile=$1
  3.  
  4. function extract_hosts() {
  5. cat $_hostFile | awk -F ',' '(NF && !/^($|#)/) {print $1, $6, $7, $8, $9}'
  6. }
  7.  
  8. while IFS=' ' read _HOST _USER _PASS _FILE _DEST
  9. do
  10. expect -c "
  11. set timeout 2
  12. log_file bulkScp.log
  13. spawn scp $_FILE $_USER@$_HOST:$_DEST
  14.  
  15. expect {
  16. "*yes*" { send "yes"\r }
  17. exit
  18. }
  19. expect {
  20. "*pass*" { send $_PASS\r; exp_continue}
  21. }
  22. "
  23. done < <(extract_hosts)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement