In principle you can use any process which output are code-lines and pipe that in ksh (or any other shell i know, for that matter):
typeset -i iCnt=0
while [ $iCnt -le 10 ] ; do
print - "echo foo $iCnt bar"
(( iCnt += 1 ))
done | ksh
Notice, however, that there are certain things to be aware of:
First, your lines have to observe the line-length limit the system is compiled with. This is always the case but when writing lines of code you notice extraordinary long lines more easily than when you generate them.
typeset -i iCnt=0
var="echo "
while [ $iCnt -le <some-big-number> ] ; do
var="$var $iCnt"
(( iCnt += 1 ))
done
print - $var | ksh
This will eventually break for either the line " var="$var $iCnt
" being too long, the number of maximum arguments being exceeded or the maximum commandline length being exceeded. Which of these events will happen first and at which value of some-big-number depends on your system, the version, etc..
Another possible problem is possible multiple interpretations of your commandline by a shell. Consider a try to execute a command on several selected hosts:
sed '.....' /some/raw/listofhosts |\
while read chHost ; do
print - "ssh user@$chHost /some/command"
done | ksh
In this form it would work, because the commandline will not change with several shells interpreting it, but how about a command which should receive several parameters, some of them containing spaces:
ssh user@host /some/command "first arg" "second arg"
This will work on the commandline, but in your script-constructing script you would have to do:
sed '.....' /some/raw/listofhosts |\
while read chHost ; do
print - "ssh user@$chHost /some/command \"first arg\" \"second arg\""
done | ksh
I hope this helps.
bakunin