Sponsored Content
Top Forums Shell Programming and Scripting Shell script not exiting Gracefully Post 302106296 by sb008 on Wednesday 7th of February 2007 05:41:22 PM
Old 02-07-2007
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
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

exiting from script

there are many script in my project.i am having a problem when i am trying to quit from child script.what is the command to wrap up all the parent script and calling script as well? exit 0 is not working.please help.... (1 Reply)
Discussion started by: arghya_owen
1 Replies

2. Shell Programming and Scripting

Shell script..invoking command and exiting at fixed intervals

Hi, I need to write a shell script. Based on command line param to script say demode=yes Need to run an ant command for an hour(configurable) Then exit Again run the ant command all this needs to be in a loop. Thanks in advance Raj (1 Reply)
Discussion started by: rajuak12
1 Replies

3. Shell Programming and Scripting

Exiting a script

I have a script abc.sh. Its contents are as follows: (7 Replies)
Discussion started by: lassimanji
7 Replies

4. Shell Programming and Scripting

shell script exiting before completing

I have a script which has the following statement, /opt/oracle/product/9i/bin/sqlplus << EOC >> $LOG_FILE 2>&1 username/password ---- Enters the SQL prompt @/export/home/oracle/shells/grant_userview.sql ---Runs the SQL script @/export/home/oracle/shells/grant_proc_userview.sql ---Runs the... (6 Replies)
Discussion started by: welldone
6 Replies

5. Shell Programming and Scripting

exiting from script

Hi, I am trying to exit the script from a function. I was in assumption that if we use exit ( inside or outside the function) it will exit from the script. alternatively, return will exit from that particular function. but in my case, exit is exiting from the function and not the script.... (8 Replies)
Discussion started by: shellwell
8 Replies

6. Shell Programming and Scripting

"Odd" behavior exiting shell script

Is it normal behavior for a shell script that terminates to terminate its parent shell when executed with the "." option? For example, if I have the example script (we'll name it ex.sh): #!/bin/sh if then echo "Bye." exit 2 fi And I execute it like this: >./ex.sh It... (6 Replies)
Discussion started by: DreamWarrior
6 Replies

7. Shell Programming and Scripting

Exiting out of the script

I have to write a script in ksh which again should call another script. Say A.ksh is calling B.ksh. Now in B.ksh if the condition we are checking for is true then we have to go back to the main script A.ksh or if the condition in B.ksh is false then we have to totally come out of the scripts. I... (1 Reply)
Discussion started by: vpv0002
1 Replies

8. Solaris

Unable to install Sol10 on V245, exiting to shell.

Hi there, OK so I am super-green, but I have a problem I am hoping someone can help me with. I have a V245 that I am unable to install Solaris 10 (10/09) onto as during the initial install process, the UI pops up for region selection, but then as I enter my region, identify the system, up comes... (21 Replies)
Discussion started by: wallrunn3r
21 Replies

9. Programming

Closing Socket Gracefully Solaris

Hi All I am creating one client socket with SO_LINGER option Disabled struct linger LingerState = {0, 0}; if (setsockopt(_hSocketTCP, SOL_SOCKET, SO_LINGER, (const char *) &LingerState, sizeof(struct linger)) == -1) { cout<<"Cannot set linger to 0 for socket"<<endl... (0 Replies)
Discussion started by: mr_deb
0 Replies

10. Shell Programming and Scripting

Exiting from Minicom on a shell script

This is what I've tried: #!/bin/sh send sh send showifs send exit ! killall minicom My problem is that for some reason when I do this it doesn't give me the results of the prior commands sent like showifs So I suspect my syntax is wrong. (1 Reply)
Discussion started by: uradunce
1 Replies
GZFORCE(1)						      General Commands Manual							GZFORCE(1)

NAME
gzforce - force a '.gz' extension on all gzip files SYNOPSIS
gzforce [ name ... ] DESCRIPTION
gzforce forces a .gz extension on all gzip files so that gzip will not compress them twice. This can be useful for files with names trun- cated after a file transfer. On systems with a 14 char limitation on file names, the original name is truncated to make room for the .gz suffix. For example, 12345678901234 is renamed to 12345678901.gz. A file name such as foo.tgz is left intact. SEE ALSO
gzip(1), gznew(1), gzmore(1), gzgrep(1), gzdiff(1), gzexe(1) ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWgzip | +--------------------+-----------------+ |Interface Stability | External | +--------------------+-----------------+ NOTES
Source for gzip is available in the SUNWgzipS package. GZFORCE(1)
All times are GMT -4. The time now is 01:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy