You are here : python_2ososmknod

os.mknod() - os

             

The method mknod() creates a filesystem node (file, device special file or named pipe) named filename.


  • filename -- This is the filesystem node to be created.

  • mode -- The mode specifies both the permissions to use and the type of node to be created combined (bitwise OR) with one of the values stat.S_IFREG, stat.S_IFCHR, stat.S_IFBLK, and stat.S_IFIFO. They can be ORed base don requirement.

  • device -- This is the device special file created and its optional to provide.


Syntax


os.mknod(filename[, mode=0600[, device=0]])


Example


# !/usr/bin/python

import os
import stat

filename = '/tmp/tmpfile'
mode = 0600|stat.S_IRUSR

# filesystem node specified with different modes
os.mknod(filename, mode)


Output / Return Value

Let us compile and run the above program, this will create a simple file in /tmp directory with a name tmpfile:


-rw-------. 1 root root 0 Apr 30 02:38 tmpfile


Limitations


Alternatives / See Also


Reference