The reason it's failing with this error is the interpolation of $(seq 1 $k)
inside your fanout
command.
Let me explain...
Running seq 1 2
returns this:
1
2
You have that inside double quotes, so the newline is kept as significant text. The fanout command therefore evaluates to this:
fanout server1 'umask 022 ; for k in 1
2 ; do for i in ear2 ; do echo /appl/as/bin/md5 /appl/as/var/spool/ears/abc/ ; done ; done'
Your ksh
does not understand the 2
on the second line, so it bails.
You can fix this with the inclusion of xargs
, but then you hit a second potential problem where you're using k
as a loop counter, but the $k
is evaluated before the loop runs. Furthermore, you have a subshell where $ears
needs to be evaluated before the script runs but it's used within a loop that changes at runtime.
I've found a man page for fanout
but I don't understand why you're running your loop against a single system (server1
) when fanout
exists to run a command against multiple systems. If you can explain the difference between a server and an ear I might be able to suggest a cleaner piece of code. My first suggestion might be this, though:
ears='ear1,ear2'
cluster=abc
dmgr=server1
fanout "$dmgr" "/appl/as/bin/md5 /appl/as/var/spool/ears/${cluster}/{$ears}"
"
in your fanout command. please try after correcting it ? – NewLands Sep 30 '15 at 7:392
on line 2. Also what you posted lacks a#!
line. Post your actual, complete script if you want help. And fix your Shift key. – Gilles Sep 30 '15 at 22:26