🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #11120

Re: generar ficheros que no se machaquen

#11120
From: Xavier Montero
Date: Sat, 29 Dec 2001 20:58
38 lines
2491 bytes
>         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...

Aunque te han sugerido mktemp, lo correcto es usar tmpfile porque
as� tu programa es compatible con el ANSI-C en ese aspecto; usando
las librerias ANSI siempre somos m�s compatibles, y si el resultado
comple lo que necesitamos (en este caso un archivo temporal) no
necesitamos ligarnos a nada m�s particular.

xavi@inspire:~$ man tmpfile

TMPFILE(3)          Linux Programmer's Manual          TMPFILE(3)

NAME
       tmpfile - create a temporary file

SYNOPSIS
       #include <stdio.h>

       FILE *tmpfile (void);

DESCRIPTION
       The  tmpfile() function generates a unique temporary file�
       name using the path prefix P_tmpdir defined in  <stdio.h>.
       The  temporary  file  is  then opened in binary read/write
       (w+b) mode.  The file will be automatically  deleted  when
       it is closed or the program terminates.

RETURN VALUE
       The  tmpfile()  function  returns  a stream descriptor, or
       NULL if a unique  filename  cannot  be  generated  or  the
       unique file cannot be opened.

-- 
Xavier Montero - Digital Sound Items, scp
Tel: 93 589 71 91 - Fax: 93 590 10 96 - Cell: 630 59 01 62
www.dsitelecom.com - xmontero@dsitelecom.com
Technical Details
Message-ID: <3C2E2E87.D0C2B1CE@dsitelecom.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeeds.belnet.be!news.belnet.be!opentransit.net!newsfeed.comtenidos.com!newsfeeder.wanadoo.es!news.antakira.com!not-for-mail
References: <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-29 14:01:03 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newsfeeds.belnet.be!news.belnet.be!opentransit.net!newsfeed.comtenidos.com!newsfeeder.wanadoo.es!news.antakira.com!not-for-mail
From: Xavier Montero <xmontero@dsitelecom.com>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: generar ficheros que no se machaquen
Date: Sat, 29 Dec 2001 21:58:47 +0100
Organization: Digital Sound Items
Lines: 38
Message-ID: <3C2E2E87.D0C2B1CE@dsitelecom.com>
References: <3c2c5015.8267927@news.mad.ttd.net>
NNTP-Posting-Host: 212.25.147.135
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: news.wanadoo.es 1009662891 11434 212.25.147.135 (29 Dec 2001 21:54:51 GMT)
X-Complaints-To: usenet@wanadoo.es
NNTP-Posting-Date: Sat, 29 Dec 2001 21:54:51 +0000 (UTC)
X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U)
X-Accept-Language: en