![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| exiting from script | arghya_owen | Shell Programming and Scripting | 1 | 06-02-2008 06:36 AM |
| Exiting from script when error occurs | Sreejith_VK | Shell Programming and Scripting | 4 | 04-25-2008 03:53 AM |
| Script Not Exiting??? | lesstjm | Shell Programming and Scripting | 1 | 07-11-2007 11:58 AM |
| PHP5 Script 'Freeze' before exiting | Unbeliever | Shell Programming and Scripting | 4 | 05-10-2007 11:32 AM |
| exiting in c | ruffenator | High Level Programming | 3 | 04-28-2002 02:31 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Shell script not exiting Gracefully
Hi
we are seeing strange behaviour , when we execute shell script it is successfully executing but it's PID is still hanging when we see ps -ef | grep script1.ksh until we do Kill <PID> $script1.ksh $ $ ps -ef | grep script1.ksh user1 249996 1 0 10:48:40 pts/1 0:00 /usr/bin/ksh script1.ksh Inside script we are using exit command before completion of script OS : AIX 5.3.0.0 Can someone advise Let me know if you need any additional information . thanks 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 |
|
||||
|
Quote:
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 |
|
||||
|
I think yes
gzip -1 < NAMEDPIPE_FILE > EXPORT_FILE & causing the issue , we are writting to the pipe since we don't have enough space on filesystem to export data , we write data into Pipe and then compress in the background . we can't do like this db2 "export to NAMEDPIPE of del select * from test" & gzip -1 < NAMEDPIPE > EXPORT.gz Since if we hvae any error on export like table not found ... next step gzip is waitting for the PIPEFILE , and script itself is hanging without proceeding to next step. Any insight ? thanks smithk |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|