Script Not waiting....plz help

Hi All:
I am trying to call a multi-step script from a script.
here is the code

#!/usr/bin/ksh

util.sh <<EOF
 connect 
 dump
EOF

I am able to run the script but it is disconnecting before the dump job is finished. The script util.sh does not provide any functionality to wait till the job is finished. Is there a way in ksh to wait till the job is done?

A couple of thoughts based on what you provided:
(a) Can you issue those two commands manually? Does the connect "time-out" anyway during the dump?
(b) How big is the dump? Is it possible that the dump is error'ing, perhaps by filling available space or exceeding some quota? This could give the impression that the connect is timing-out; but in fact the dump would be causing the problem.

joey thanks for the reply.

the individual commands run till the jobs are done.

if i run the commands individually, after connect it will lead to a console and wait until exit is issued. For the dump command, it will wait till the job is finished.

But when run through the above code, even the connect is closing the session after a while. This could be related to the shell behavior.

any ideas...plz suggest something

In other words,
(a) does the dump end at exact/about the same filesize?
(b) does the dump end after similar amounts of elapsed time?

Run a couple of times and see what the pattern is.
(a) could mean exceeding some threshold: filesize, allocation, available space
(b) general time-out; think of a screen-saver that blanks a screen even though a program is running since it has not sensed keyboard entry in xx time.

Joey:
As I mentioned in my previous post: The script when run alone, after connect it will wait until the "exit" command is issued. So when we run the dump, it is producing 10MB file (this is expected size).

When I try to automate using shell script: the dump disconnects and the size I am getting is random, between 4-5MB.

Also, I tried

#!/usr/bin/ksh

util.sh <<EOF
 connect 
EOF

and even this code disconnects after a while(after executing connect), but when I run the util.sh standalone, after connect it wait indefinitely for the commands and will exit when the exit command is issued. So this means that the Shell is disconnecting.

There might be a way to wait until the job is done.

Please note that I can not change "util.sh" as it is using Java classes and it is supplied by vendors.

Do you get a message on disconnect? Or do you just know 'after' since you see it aborted? Since the file is building to simlar size range, I am lef to wonder if there is some time-out on batch at 900 seconds or other value.
So, can you see if three failures all occur about the same timeframe? If so, then this may be the 'cause' of the matter.

joey...

no matter what command i use between <<EOF and EOF, all the commands are terminated after a while with the same exception that is coming from java class which util.sh is using.

The thing is that when i run the same commands (that are in <<EOF and EOF) seperately...the commands are not terminated until they are finished. Further the console waits for "exit" command to exit the console.

If you still asking questions...then we are wasting time to understand the behaviour of util.sh.

It is the shell which is disconnecting after supplying the commands to util.sh (that are in between <<EOF and EOF).

What I am looking for is a way to run the commands inside <<EOF and EOF while waiting till the commands are finished. I wonder whether it is possible if we use <<EOF...EOF ?????

first off - the problem is probably in util.sh.

Since we are "black-boxing" util.sh it makes it really hard. I think you are getting a SIGHUP sent to a child process in util.sh, so let's try a nohup...
This script assumes util.sh uses read to get commands

# script1
echo "
connect
dump 
" | util.sh
nohup script1 &
wait

It would be far easier to nohup whatever is going on inside util.sh.... this is just a (probably) bad guess.

jim thanks for the suggestion.

I tried it and still no luck.

Probably I need to follow up with the vendor.