[comp.unix.questions] Removing shell temp files

dpulyk@nro.cs.athabascau.ca (Dennis Pulyk) (04/22/91)

Is there a way to get the shell (bourne) to remove temporary files that 
it creates from 'here is' documents? . We use shell scripts that use the 
form cat <<! ... and if the shell gets killed off (ie from autologoff 
routines, etc) files of the form /tmp/shxxxx are left floating around. 
Other then periodically cleaning up /tmp, is there a better way to get 
the shell to clean up its act??
Much thanx for any help.

Dennis Pulyk             ersys!dpulyk@nro.cs.athabascau.ca
Edmonton Remote Systems:  Serving Northern Alberta since 1982

urban@cbnewsl.att.com (john.urban) (04/23/91)

In article <T38s11w164w@ersys.uucp> ersys!dpulyk@nro.cs.athabascau.ca (Dennis Pulyk) writes:
>Is there a way to get the shell (bourne) to remove temporary files that 
>it creates from 'here is' documents? . We use shell scripts that use the 
>form cat <<! ... and if the shell gets killed off (ie from autologoff 
>routines, etc) files of the form /tmp/shxxxx are left floating around. 
>Other then periodically cleaning up /tmp, is there a better way to get 
>the shell to clean up its act??
>Much thanx for any help.
>
>Dennis Pulyk             ersys!dpulyk@nro.cs.athabascau.ca
>Edmonton Remote Systems:  Serving Northern Alberta since 1982

This is an old bug in the bourne shell which has been fixed in the lastest
releases.

For example, the bourne shell on UNIX System V/386 Release 3.2 Version 2.2
does not have this problem.


In the short term, you could add this little front end to your here shell scripts ...

sh <<!
ls -l /tmp
rm -rf /tmp/sh$$*
ls -l /tmp
exit
!

As you see your /tmp/shxxxx file is gone.

However, for your cat <<!, this won't work.

Sincerely,

John Urban