Mkstemp – Visara Master Console Center Scripting Guide User Manual
Page 148
![background image](https://www.manualsdir.com/files/808700/content/doc148.png)
Chapter 5 Script Commands
Scripting Guide
148
MKSTEMP
Syntax:
MKSTEMP($Pattern) ==> %FileHandle
Description:
Opens a unique temporary file for I/O access.
Action:
A file that guaranteed to be uniquely named and not accessible by
any other process is opened for read/write access. As this is a
temporary file, it will be removed from the system at the time the
calling script terminates.
Parameters:
$Pattern: String expression. This is a case sensitive template to
be used by the system to create a filename. The last six character
of the template must be XXXXXX (all uppercase) and these are
replaced with a string that makes the filename unique. The file is
created with mode read/write and permissions 0666. The file is
opened for exclusive access guaranteeing that when this routine
returns successfully, this script will be the only user.
Returns:
Numeric value, as follows:
-1 = Error occurred while attempting to create and open the file.
Any other value = A unique number used for subsequent access to
the file in the current script (commonly referred to as the "file
handle" or the "file number").
Example:
%tmpfile := MKSTEMP("/usr/ics/tmp/foobarXXXXXX")
IF ( %tmpfile == -1 )
LOG( LOG_FLT, "Error creating temporary file!", 6)
ELSE
LOG( LOG_FLT, "File handle is " + STR(%handle), 6)
%rc := FWRITE( %tmpfile, "Here is some output",
TRUE )
IF ( %rc == 0 )
LOG( LOG_FLT, "Error writing to temporary file!",
6)
ELSE
%rc := FREAD( %tmpfile, $FirstWord )
IF ( %rc == 1 )
LOG( LOG_FLT, "Read '" + $FirstWord + "'", 6)
ENDIF
ENDIF
ENDIF
See Also: