Advertisement
Guest User

Untitled

a guest
Feb 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. im using the command below to merge file1 and file2 to get file3 :
  2. awk 'NR==FNR {a[$2]=$1; next} {$(NF+1) = a[$NF]} 1' file2 file1 > file3
  3. when i use this command inside bash script using expect im getting the file3 empty (the command is working manually).
  4.  
  5. script :
  6.  
  7. #!/bin/bash
  8. # Bash Menu Script Example
  9.  
  10. outputMME="$( expect <<END
  11. spawn ssh atndn@x.x.x.x
  12. expect "Password: " { send "passwordr" }
  13. expect "# " { send "bashr" }
  14. expect "$ " { send "cd /tmp/DPE_CORE/home/atndn/eniq/r" }
  15. expect "$ " { send "awk 'NR==FNR{a[$2]=$1; next} {\$(NF+1) = a[$NF]} 1' file2 file1 > file3r" }
  16. END
  17. )"
  18.  
  19. echo "$outputMME"
  20.  
  21. 471808241 29164840 1 10001 156197396
  22. 471722917 21067410 1 31001 135961856
  23. 471941441 20774160 1 7001 180995072
  24. 471568655 29042630 1 15001 157502996
  25. 471524711 20716360 1 4001 180226817
  26. 471873918 29583520 1 2001 128567298
  27. 471568650 29042631 1 15002 157502910
  28.  
  29. 610146 156197396
  30. 531101 135961856
  31. 704011 180226817
  32. 502216 128567298
  33. 707012 180995072
  34. 615246 157502996
  35. 685221 157502910
  36.  
  37. 471808241 29164840 1 10001 156197396 610146
  38. 471722917 21067410 1 31001 135961856 531101
  39. 471941441 20774160 1 7001 180995072 707012
  40. 471568655 29042630 1 15001 157502996 615246
  41. 471524711 20716360 1 4001 180226817 704011
  42. 471873918 29583520 1 2001 128567298 502216
  43. 471568650 29042631 1 15002 157502910 685221
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement