Hi guys,
I have a scenario where i want to run a script from Node A. It ssh's into Node B and runs some awk commands there plus deposiriting the output on Node B.
Challenge is that the awk commands run properly when executed locally on Node B but fail when within the script on Node B. I do not get the desired output in this case.
#!/bin/ksh
(/export/home/doodie/node_call NODE1) 2>&1
(/export/home/doodie/node_call NODE2) 2>&1
(/export/home/doodie/node_call NODE3) 2>&1
# cat node_call
#!/bin/ksh
# GET SOME DATA
case $1
in
NODE1)
name=SD1
node=sd1b
;;
NODE2)
name=SD2
node=sd2b
;;
NODE3)
name=SD3
node=sd3b
;;
*)
;;
esac
DT=$(date '+%Y%m%d')
ssh -i /SSH_KEYS/keys user@$node <<EF
cd /var/direct/
awk 'BEGIN {print "ID_NAME,ID,BAL,STATUS,EXP1,EXP2"} {FS=OFS=",";print $1,$18,$21,$22,$23,$24}' "$name".file1.csv > "$name"_data1_"$DT"
EF
The raw files are
$ cat file1.csv
213039892,3273039892,0,0,,0,0,1,0,0,0,0,0,0,0,0,0,5,5,,0.000000,1,2011-12-13,2011-12-13,,2012-03-12,0,0,2012-03-12,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-09-14
213532518,3273532518,0,0,,0,1,1,0,0,0,1,0,0,0,0,0,5,5,,5.675000,1,2012-09-14,2012-09-14,,2013-06-11,0,0,2013-03-13,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-07-27
212082217,3282082217,0,0,,0,1,1,0,0,0,1,0,0,0,0,0,5,5,,11.775000,1,2012-07-05,2012-07-05,,2013-04-01,0,0,2013-01-01,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-07-11
213608503,3273608503,0,1,,0,1,1,0,0,0,1,0,0,0,0,0,5,5,,2.575000,1,2012-09-08,2012-09-08,,2013-06-05,0,0,2013-03-07,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-07-21
217427440,3277427440,0,0,,0,0,1,0,0,0,0,0,1,0,1,0,5,5,,0.000000,0,,,,,0,0,,0,0,,0,0,0,0,0,0,0,0,0,0,0,
215677789,3285677789,0,0,,1,1,1,0,0,0,1,0,0,0,0,0,5,5,,477.550000,1,2012-09-16,2012-09-16,,2013-06-13,0,0,2013-03-15,0,0,,0,0,0,0,0,0,0,0,0,0,0,2010-01-24
215970109,3285970109,0,0,,0,1,1,0,0,0,0,0,0,0,0,0,31,31,,6.810000,1,2011-05-30,2011-05-30,,2012-02-24,0,0,2011-11-26,0,0,,0,0,0,0,0,0,0,0,0,0,0,2010-02-21
219096998,3279096998,0,0,,0,0,1,0,0,0,0,0,1,0,1,0,5,5,,0.000000,0,,,,,0,0,,0,0,,0,0,0,0,0,0,0,0,0,0,0,
219856498,3279856498,0,0,,0,0,1,0,0,0,0,0,1,0,1,0,5,5,,0.000000,0,,,,,0,0,,0,0,,0,0,0,0,0,0,0,0,0,0,0,
213867504,3273867504,0,0,,1,1,1,0,0,0,0,0,0,0,0,0,5,5,,811.625000,1,2012-09-16,2012-09-16,,2013-06-13,0,0,2013-03-15,0,0,,0,0,0,0,0,0,0,0,0,0,0,2011-02-16
Expected output
$ cat SD1_data1_20110923
ID_NAME,ID,BAL,STATUS,EXP1,EXP2
213039892,5,0.000000,1,2011-12-13,2011-12-13
213532518,5,5.675000,1,2012-09-14,2012-09-14
212082217,5,11.775000,1,2012-07-05,2012-07-05
213608503,5,2.575000,1,2012-09-08,2012-09-08
217427440,5,0.000000,0,,
215677789,5,477.550000,1,2012-09-16,2012-09-16
215970109,31,6.810000,1,2011-05-30,2011-05-30
219096998,5,0.000000,0,,
219856498,5,0.000000,0,,
Output now
ID_NAME,ID,BAL,STATUS,EXP1,EXP2
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4
,,1,2,3,4
---
Mod addendum: nice attempt to use code tags... Look at: