154 lines
3.6 KiB
HTML
154 lines
3.6 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of TEMPFILE</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>TEMPFILE</H1>
|
|
Section: User Commands (1)<BR>Updated: 27 Jun 2012<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
tempfile - create a temporary file in a safe manner
|
|
<A NAME="lbAC"> </A>
|
|
<H2>SYNOPSIS</H2>
|
|
|
|
<B>tempfile</B>
|
|
|
|
[-d DIR] [-p STRING] [-s STRING] [-m MODE] [-n FILE] [--directory=DIR]
|
|
[--prefix=STRING] [--suffix=STRING] [--mode=MODE] [--name=FILE] [--help] [--version]
|
|
<A NAME="lbAD"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
<P>
|
|
|
|
<B>tempfile</B>
|
|
|
|
creates a temporary file in a safe manner. It uses
|
|
<B><A HREF="/cgi-bin/man/man2html?3+mkstemps">mkstemps</A></B>(3)
|
|
|
|
to choose the name and opens it with O_RDWR | O_CREAT | O_EXCL. The filename
|
|
is printed on standard output.
|
|
<P>
|
|
|
|
The directory in which to create the file might be searched for in this
|
|
order:
|
|
<DL COMPACT>
|
|
<DT id="1">a)<DD>
|
|
In case the environment variable
|
|
<B>TMPDIR</B>
|
|
|
|
exists and
|
|
contains the name of an appropriate directory, that is used.
|
|
<DT id="2">b)<DD>
|
|
Otherwise, if the
|
|
<I>--directory</I>
|
|
|
|
argument is specified and appropriate, it is used.
|
|
<DT id="3">c)<DD>
|
|
Otherwise,
|
|
<I>P_tmpdir</I>
|
|
|
|
(as defined in
|
|
<I><<A HREF="file:///usr/include/stdio.h">stdio.h</A>></I>)
|
|
|
|
is used when appropriate.
|
|
<DT id="4">d)<DD>
|
|
Finally an implementation-defined directory
|
|
<I>(/tmp)</I>
|
|
|
|
may be used.
|
|
</DL>
|
|
<A NAME="lbAE"> </A>
|
|
<H2>OPTIONS</H2>
|
|
|
|
<DL COMPACT>
|
|
<DT id="5"><B>-d, --directory </B><I>DIR</I>
|
|
|
|
<DD>
|
|
Place the file in DIR.
|
|
<DT id="6"><B>-m, --mode </B><I>MODE</I>
|
|
|
|
<DD>
|
|
Open the file with MODE instead of 0600.
|
|
<DT id="7"><B>-n, --name </B><I>FILE</I>
|
|
|
|
<DD>
|
|
Use FILE for the name instead of
|
|
<B><A HREF="/cgi-bin/man/man2html?3+tempnam">tempnam</A></B>(3)<B>.</B>
|
|
|
|
The options -d, -p, and -s are ignored if this option is given.
|
|
<DT id="8"><B>-p, --prefix </B><I>STRING</I>
|
|
|
|
<DD>
|
|
Use up to five letters of STRING to generate the name.
|
|
<DT id="9"><B>-s, --suffix </B><I>STRING</I>
|
|
|
|
<DD>
|
|
Generate the file with STRING as the suffix.
|
|
<DT id="10"><B>--help</B>
|
|
|
|
<DD>
|
|
Print a usage message on standard output and exit successfully.
|
|
<DT id="11"><B>--version</B>
|
|
|
|
<DD>
|
|
Print version information on standard output and exit successfully.
|
|
</DL>
|
|
<A NAME="lbAF"> </A>
|
|
<H2>RETURN VALUES</H2>
|
|
|
|
An exit status of 0 means the temporary file was created successfully.
|
|
Any other exit status indicates an error.
|
|
<A NAME="lbAG"> </A>
|
|
<H2>BUGS</H2>
|
|
|
|
Exclusive creation is not guaranteed when creating files on NFS
|
|
partitions. tempfile cannot make temporary directories.
|
|
tempfile is deprecated; you should use <A HREF="/cgi-bin/man/man2html?1+mktemp">mktemp</A>(1) instead.
|
|
<A NAME="lbAH"> </A>
|
|
<H2>EXAMPLE</H2>
|
|
|
|
<P>
|
|
<DL COMPACT><DT id="12"><DD>
|
|
<PRE>
|
|
#!/bin/sh
|
|
#[...]
|
|
t=$(tempfile) || exit
|
|
trap "rm -f -- '$t'" EXIT
|
|
#[...]
|
|
rm -f -- "$t"
|
|
trap - EXIT
|
|
exit
|
|
</PRE>
|
|
|
|
</DL>
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+tempnam">tempnam</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?1+mktemp">mktemp</A></B>(1)
|
|
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="13"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="14"><A HREF="#lbAC">SYNOPSIS</A><DD>
|
|
<DT id="15"><A HREF="#lbAD">DESCRIPTION</A><DD>
|
|
<DT id="16"><A HREF="#lbAE">OPTIONS</A><DD>
|
|
<DT id="17"><A HREF="#lbAF">RETURN VALUES</A><DD>
|
|
<DT id="18"><A HREF="#lbAG">BUGS</A><DD>
|
|
<DT id="19"><A HREF="#lbAH">EXAMPLE</A><DD>
|
|
<DT id="20"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:28 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|