SUMMARY: here document temporary files

From: Clemens Vonrhein <vonrhein_at_GlobalPhasing.com>
Date: Wed, 16 Feb 2000 07:01:40 +0000 (GMT)

Thanks to

  Bob Vickers <bobv_at_dcs.rhbnc.ac.uk>
  Tom Blinn <tpb_at_doctor.zk3.dec.com>
  Alex Gorbachev <alex_at_iss-integration.com>

for answering my question (appended) about temporay files used by
Bourne shell in here documents (to do variable and command
substitution).

The real answer seems to be, that there might be a problem in /bin/sh
under 4.0E. The funny thing is, it seems to happen only with fairly
complicated scripts (and maybe only if started from an Apache cgi
script written in perl?).

Anyway, some ways around it, that are unfortunately not possible for
me (untested):

1. use /bin/ksh (or any other shell for that matter) instead of
   /bin/sh

2. since all temporary files look like /tmp/sh<PID><num>, where <PID>
   is the process ID of the current shell ($$) it should be possible
   to do a

     /bin/rm /tmp/sh$$*

   at the end of the script

Cheers

Clemens

----- original message ----------------------------

Dear all,

I've got some problems with here-documents. From the Bourne shell man
page (1b) I can see:

  The shell creates a temporary file containing the input document and
  performs variable and command substitution on its contents before
  passing it to the command.

Since I'm running shell scripts with a lot of here documents, like

program <<end_ip
KEY $key1
KEY $key2
end_ip

I end up with THOUSANDS of these temporary files in /tmp. They seem to
be called sh<PID><num> with increasing <num> for each here
document. At some stage one of the scripts will crash, because the
temporary file already exists. Why does the shell not remove the file
once it has done the variable substitution? The script runs fine under
Linux and IRIX ...

I'm running Digital UNIX V4.0E (Rev. 1091) on a DS20 if that is of any
significance. The /bin/sh scripts are started by an apache 1.3.6 httpd
via CGI scripts (perl5).

I've got the feeling that some shell setup is not done properly - or
do I just have to run a cronjob every 30min to clean up /tmp?

----- End of original message-----

-- 
****************************************************************
* Clemens Vonrhein, Ph.D.          vonrhein_at_GlobalPhasing.com  *
*                                                              *
*         Global Phasing Ltd.                                  *
*         Sheraton House, Castle Park                          *
*         Cambridge CB3 0AX, UK                                *
*    Tel: +44-(0)1223-353033   Fax: +44-(0)1223-366889         *
*--------------------------------------------------------------*
* BUSTER Development Group (http://Lagrange.mrc-lmb.cam.ac.uk) *
****************************************************************
Received on Wed Feb 16 2000 - 07:06:46 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:40 NZDT