Article View: es.comp.os.linux.programacion
Article #11111Re: generar ficheros que no se machaquen
From: Santiago Romero
Date: Fri, 28 Dec 2001 11:06
Date: Fri, 28 Dec 2001 11:06
40 lines
2073 bytes
2073 bytes
El Fri, 28 Dec 2001 10:58:40 GMT, Javier Loureiro Varela escribi๏ฟฝ:
> Estoy haciendo un script que necesita crear un temporal para
> grabar una salida... pero no se que comando del bash hay para darle un
> nombre aleatorio no concurrente...
man mktemp
EXAMPLES
The following sh(1) fragment illustrates a simple use of mktemp where the
script should quit if it cannot get a safe temporary file.
p=`basename $0`
TMPFILE=`mktemp /tmp/$p.XXXXXX` || exit 1
echo "program output" >> $TMPFILE
In this case, we want the script to catch the error itself.
p=`basename $0`
TMPFILE=`mktemp -q /tmp/$p.XXXXXX`
if [ $? -ne 0 ]; then
echo "$0: Can't create temp file, exiting..."
exit 1
fi
SEE ALSO
mkstemp(3), mktemp(3), tempfile(1)
--
Santiago Romero
Departamento de Sistemas
sromero@servicom2000.com
Av. Primado Reig 189, entlo
46020 Valencia - Spain
Telf. (+34) 96 332 12 00
Fax. (+34) 96 332 12 01
http://www.servicom2000.com
Technical Details
Message-ID:
<slrna2okhe.h61.sromero@compiler.servicom2000>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!top.servicom2000.COM!not-for-mailReferences:
<3c2c5015.8267927@news.mad.ttd.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f86c8,735922ea4c4ad7b7 X-Google-Attributes: gidf86c8,public X-Google-ArrivalTime: 2001-12-28 03:08:31 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!130.133.1.3!fu-berlin.de!uni-berlin.de!top.servicom2000.COM!not-for-mail From: sromero@servicom2000.com (Santiago Romero) Newsgroups: es.comp.os.linux.programacion Subject: Re: generar ficheros que no se machaquen Date: Fri, 28 Dec 2001 12:06:22 +0100 Lines: 41 Message-ID: <slrna2okhe.h61.sromero@compiler.servicom2000> References: <3c2c5015.8267927@news.mad.ttd.net> Reply-To: sromero@servicom2000.com NNTP-Posting-Host: top.servicom2000.com (212.101.64.178) Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: fu-berlin.de 1009537709 21075394 212.101.64.178 (16 [39726]) X-Orig-Path: 127.0.0.1!nobody User-Agent: slrn/0.9.7.1 (Linux)