Quote:
Originally Posted by smithK
I have narrowed down the issue we are using gzip in the script ..to compress the file ..we write to the pipe then we will compreess using gzip
below is the sample code
#!/usr/bin/ksh
/usr/sbin/mknod NAMEDPIPE p
gzip -1 < NAMEDPIPE > EXPORT &
db2 "export to NAMEDPIPE of del select * from test" ##db2 command to
## export data
rm -f NAMEDPIPE
After completion of the script , successfully , i still see the script PID , i don't see connection any connection to DB , Basically script is hanging in there doing nothing , I suspect gzip -1 < NAMEDPIPE > EXPORT & not termenating ....properly
Thanks
Smithk
In your script you create a background process which reads from the named pipe (gzip).
Next you start a process (db) which writes to the named pipe.
As soon as the writing process (db) is done you remove the named pipe.
Most likely by that time the reading process (gzip) did not yet complete reading all data from the named pipe.
Since the named pipe (and the data in it) has been removed the reading process will never receive an EOF.
Basically the reading process is left with an open file descriptor which refers to something that doesn't exist any more.
Therefore the gzip command will not terminate.
Since this process is a child process of your script, your script will not terminate.
It only seems as if it terminated, all it did was returning controll back to your shell. Underneath it's waitingfor a dead of child.
After executing your script, I expect you will not only be able to find your script with ps in the process table, but the gzip as well.
Furthermore, I do understand why you use a NAMED pipe for something like this.
Wouldn't it be much easier to use:
db2 "export to EXPORT of del select * from test"
gzip -1 EXPORT
I'm not familiar with the db command, but I assume
db2 " select * from test"
would produce the output to your screen.
If so, why not use an "anonymous" pipe:
db2 "select * from test" | gzip -1 - > EXPORT.gz
It might work with a NAMED pipe as well if you switch the 2 commands:
:
#!/usr/bin/ksh
/usr/sbin/mknod NAMEDPIPE p
db2 "export to NAMEDPIPE of del select * from test" & ##db2 command to
## export data
gzip -1 < NAMEDPIPE > EXPORT.gz
rm -f NAMEDPIPE