Advertisement
absolute100

Untitled

Oct 14th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. This is my bash program, just head a file with list of hosts in a cluster and ssh to it.
  2.  
  3. $myCLUSTERDIR=~/pg/myclusters
  4.  
  5. function goto() {
  6. 150 #######
  7. 151 ###### basic structure: set the DIR
  8. 152 echo 'Ssh to the first host in a cluster'
  9. 153 local gotoHost
  10. 154 if [ -z $1 ]; then
  11. 155 echo 'Must specify a cluster name'
  12. 156 echo 'Usage: gotoHost cluster_name'
  13. 157 return
  14. 158 fi
  15. 159
  16. 160 ## get the code
  17. 161 gotoHost="$(head -n 1 $myCLUSTERDIR/$1)"
  18. 162
  19. 163 ssh $gotoHost
  20. 164 }
  21.  
  22. but when i run 'goto generic_prod', it generate errors (i set -x)
  23. $ goto generic_prod
  24. + goto generic_prod
  25. + echo 'Ssh to the first host in a cluster'
  26. Ssh to the first host in a cluster
  27. + local gotoHost
  28. + '[' -z generic_prod ']'
  29. ++ head -n 1 /Users/xyz/pg/myclusters/generic_prod
  30. + gotoHost=$'10-64-149-130-uswest1bprod.xyz.com\r'
  31. + ssh $'10-64-149-130-uswest1bprod.xyz.com\r'
  32. : nodename nor servname provided, or not knownuswest1bprod.xyz.com
  33.  
  34. the ssh line is weird to me.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement