28.10.2021 Views

Python Tutorial ( PDFDrive )

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

import os, sys

# Path to be created

path = "/tmp/hourly"

os.mkfifo( path, 0644 )

print "Path is created"

Let us compile and run the above program, this will produce the following result:

Path is created

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

Description

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

filename.

Syntax

Following is the syntax for mknod() method:

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

Parameters

• 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.

Return Value

This method does not return any value.

Example

The following example shows the usage of mknod() method.

# !/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)

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

tmpfile:

TUTORIALS POINT

Simply Easy Learning

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!