Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

mktemp(3) [redhat man page]

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

NAME
mktemp - make a unique temporary file name SYNOPSIS
#include <stdlib.h> char *mktemp(char *template); DESCRIPTION
The mktemp() function generates a unique temporary file name from template. The last six characters of template must be XXXXXX and these are replaced with a string that makes the filename unique. Since it will be modified, template must not be a string constant, but should be declared as a character array. RETURN VALUE
The mktemp() function returns NULL on error (template did not end in XXXXXX) and template otherwise. If the call was successful, the last six bytes of template will have been modified in such a way that the resulting name is unique (does not exist already). If the call was unsuccessful, template is made an empty string. ERRORS
EINVAL The last six characters of template were not XXXXXX. CONFORMING TO
BSD 4.3. POSIX dictates tmpnam(3). NOTE
The prototype is in <unistd.h> for libc4, libc5, glibc1; glibc2 follows the Single Unix Specification and has the prototype in <stdlib.h>. BUGS
Never use mktemp(). Some implementations follow BSD 4.3 and replace XXXXXX by the current process id and a single letter, so that at most 26 different names can be returned. Since on the one hand the names are easy to guess, and on the other hand there is a race between test- ing whether the name exists and opening the file, every use of mktemp() is a security risk. The race is avoided by mkstemp(3). SEE ALSO
mkstemp(3), tempnam(3), tmpfile(3), tmpnam(3) GNU
1993-04-03 MKTEMP(3)

Check Out this Related Man Page

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

NAME
mkdtemp - create a unique temporary directory SYNOPSIS
#include <stdlib.h> char *mkdtemp(char *template); DESCRIPTION
The mkdtemp() function generates a uniquely-named temporary directory from template. The last six characters of template must be XXXXXX and these are replaced with a string that makes the directory name unique. The directory is then created with permissions 0700. Since it will be modified, template must not be a string constant, but should be declared as a character array. RETURN VALUE
The mkdtemp() function returns a pointer to the modified template string on success, and NULL on failure, in which case errno is set appro- priately. ERRORS
EINVAL The last six characters of template were not XXXXXX. Now template is unchanged. Also see mkdir(2) for other possible values for errno. CONFORMING TO
Introduced in OpenBSD 2.2. Available since glibc 2.1.91. SEE ALSO
mkdir(2), mkstemp(3), mktemp(3), tmpnam(3), tempnam(3), tmpfile(3) GNU
2001-10-07 MKDTEMP(3)
Man Page

14 More Discussions You Might Find Interesting

1. Post Here to Contact Site Administrators and Moderators

Templates

Hello, Anybody in here has any idea where I can get a template like this one for vBulletin. I have actually got my board but it just doesn't look good in the template that I have! Thanks anyway! him (2 Replies)
Discussion started by: him
2 Replies

2. UNIX for Advanced & Expert Users

Special characters getting replaced by &Pound in Unix Environment

Hi, Please find the Question Summary below- In our email template document(.txt) bullets and Apostrophe are getting replaced by the string "&pound" in our Live environment.We are using sun solaris 8 in live. Can anybody let me know why this happens and how to prevent this . Thanks... (0 Replies)
Discussion started by: kaushik05
0 Replies

3. UNIX for Advanced & Expert Users

mktemp error

When I execute a korn shell script , I am getting the following error. "mktemp not found" Why I am getting this...is this error related to script. (6 Replies)
Discussion started by: tkbharani
6 Replies

4. Homework & Coursework Questions

Grep for modified time

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: is it possible to come up with a list of files that are modified before a certain number of hours only using the... (3 Replies)
Discussion started by: momo.reina
3 Replies

5. Shell Programming and Scripting

Help with template like solution

hi experts, i'm trying to do this: file1 is a template. might have kinds of 'funny' characters. sample: <body> <form> <p><input type="text" name="abc"/></p> &nbsp; <p><my_content></p> </form> </body> file2 is a file that contains lots of text. this might be very big. might have... (2 Replies)
Discussion started by: xjohnu
2 Replies

6. Homework & Coursework Questions

Delete restore and empty trash

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: A set of Linux shell scripts is required to allow users to ‘remove' files without them really disappearing... (1 Reply)
Discussion started by: mr100perecent
1 Replies

7. Homework & Coursework Questions

New to Unix

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I am new to Unix and I am having problems seeing the output of my program. 2. Relevant commands, code,... (2 Replies)
Discussion started by: TWhitt24
2 Replies

8. Homework & Coursework Questions

Need some help with grep

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! Hello all, I'm relatively new to Linux/Unix. Took an introductory course to get myself exposed to all the different commands so I'd be ready for my scripting class. I do know a... (3 Replies)
Discussion started by: Bob07
3 Replies

9. Homework & Coursework Questions

Unix/Linux Math Decimal to Whole Number Format?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: The problem? I hope I fill this out correctly. I have a program that runs like a cash register. It works and... (6 Replies)
Discussion started by: Iceman69
6 Replies

10. Programming

C++ template error

I get some compiling errors about template instantiation :wall: , but I can't find where the syntax errors happens. Can some help me? template<typename Type> class SingleList; template<typename Type> class SingleListNode{ private: friend class SingleList<Type>; SingleListNode() :... (1 Reply)
Discussion started by: 915086731
1 Replies

11. Homework & Coursework Questions

Understanding Getopts in an otherwise easy assignment

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: In the command line I will be given files or words which will be USER ID's or a file of USER ID's. I am to let... (4 Replies)
Discussion started by: ByronicX
4 Replies

12. Homework & Coursework Questions

Bash Script for Dice Game; Issue with if...else loop to verify user guess is within range

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have written a script for a dice game that: (1) tells user that each of the 2 die are 6 sided (Spots=6); (2)... (3 Replies)
Discussion started by: LaurenRose
3 Replies

13. Linux

Search a template file and replace with input

Hi I have a CommonTemplateStop.template file . Inside the file i need to replace the variables DepName and CompInsName with the values(Trade and TradeIns) specified in the script. I have written the below .sh script in linux server which will read the .template file and has to replace the 2... (8 Replies)
Discussion started by: samrat dutta
8 Replies

14. Solaris

Creating a VMware template

Hello, I am creating a Solaris 11 template on my ESXI host. I would like each VM that is deployed from the template to have its own unique host fingerprint. With Linux, I simply delete host keys, which causes new keys to be generated at bootup (new VM deployment) Is there a way to do this... (1 Reply)
Discussion started by: firefoxx04
1 Replies