Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SUMMARY: here document temporary files

1 view
Skip to first unread message

Clemens Vonrhein

unread,
Feb 16, 2000, 3:00:00 AM2/16/00
to tru64-uni...@ornl.gov
Thanks to

Bob Vickers <bo...@dcs.rhbnc.ac.uk>
Tom Blinn <t...@doctor.zk3.dec.com>
Alex Gorbachev <al...@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. vonr...@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) *
****************************************************************

0 new messages