>> This does not work
>>
>> some_func()
>> {
>> cat > /somefile/somewhere << EOF
>> fee fi fo fum
>> EOF
>> do_something_cool
>> }
>>
>> # MAIN
>> (
>> while true
>> do
>> some_func
>> ) &
>>
>>
>> But ... this works
>>
>> some_func()
>> {
>> do_something_cool
>> }
>>
>> # MAIN
>> (
>> while true
>> do
>> cat > /somefile/somewhere << EOF
>> fee fi fo fum
>> EOF
>> some_func
>> ) &
>>
>>
>> I need the whole bracket and & gimmick so SMF exit condition will
>> return correctly. The problem is in the first way, the file
>> /somefile/somewhere will be written with zero byte, (and probably not
>> closed, I havent checked.)
>>
>> The second way, the file is written correctly. Probably something
>> with passing an EOF from inside a function to another function
>> enclosed by ()? Anyhow, weird, interesting, and a mystery to me.
>>
>> CT
Hi,
Revisiting this, I took another route to make this work, but this
still bugs me that it does not work.
> I don't understand the question. First of all there is no matching
> done with the do.
Yes, there should have been a closing "done" in main(). In my hasty
simplification of the script, I forgot to put it in.
> Secondly, does /somefile represent a directory that exists or
> does not exist?
The /somefile/somewhere is in a directory structure that already
exists. The file may or may not exist. If the file exists it will be
clobbered.
The reason I have resorted to such hackery, running a script as an
endless while loop, is because I want this script to be a service
managed by SMF. I could easilier accomplish this with cron, but then
the service state of the system is not fully presented, since cron
jobs are out of scope for SMF.
CT