Found 10784 Articles for Python

Resource Usage Information using Python

Chandu yadav
Updated on 30-Jul-2019 22:30:23

699 Views

To measure the UNIX resource usage, we need to use the resource module into our programs. This module also can control the resource utilization. To use this module, we should import it using − import resource Resource Limits In this module we can use the setrlimit() to limit the resource utilization. There are two parameters to limit the resources. These parameters are soft limit and the hard limit. The soft limit is basically the current limit, it can be changed over process, but it cannot exceed the hard limit. The hard limit can be reduced to any value ... Read More

Python Interface to Shell Pipelines

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

237 Views

To use the UNIX command pipeline mechanism using python. In the command pipelining a sequence converts from one file to another file. This module uses /bin/sh command line. So we need os.system() and os.popen() methods. To use this module, we should import it using − import pipes The pipes holds Template class − class pipes.Template This class is basically an abstraction of a pipeline. It has different methods. These are as follows. Method Template.reset() This method is used to restore the pipeline template to its initial position. Method Template.clone() This method is used to create another new, ... Read More

The fcntl and ioctl System Calls in Python

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

2K+ Views

To control the files and the io, we should use the fcntl module. It is basically one interface to the fcntl() and ioctl() Unix routines. All methods in this module takes one integer or io.IOBase file-descriptor as their first argument. To use this module, we should import it using. import fcntl There are some modules of the fcntl module, these are − Method fcntl.fcntl(fd, op[, arg]) This method is used to perform the operation on the file using file descriptor. The operation is defined by op. The third argument is optional. It can be either integer type value ... Read More

Pseudo-terminal Utilities in Python

George John
Updated on 30-Jul-2019 22:30:23

1K+ Views

The Pseudo-terminal utility module pty is defined to handle pseudo-terminal concepts. Using this we can start another process, and also can read or write from controlling terminal using programs. This module is highly platform oriented. We should use UNIX systems to perform these operations. To use the pty module, we should import it using − import pty There are some modules of the pty module, these are − Method pty.fork() This method is used to connect the child controlling terminal to pseudo-terminal. This method returns the pid and the fd. The child process gets the pid 0, but ... Read More

Terminal Control Functions in Python

Chandu yadav
Updated on 30-Jul-2019 22:30:23

931 Views

To change the terminal controls in the Unix system, we can use the tty related methods in Python. Using the tty module, we can set two different modes of the terminal. The raw Mode and the cbreak mode. To use the tty module, we should import it using − import tty There are some modules of the tty module, these are − Method tty.setraw(fd, when = termios.TCSAFLUSH) This method is used to change the terminal mode to raw mode. In the raw mode, the cursor moves to new line but the carriage return operation is not performed. Also ... Read More

POSIX Style TTY control using Python

Ankith Reddy
Updated on 30-Jul-2019 22:30:23

358 Views

The termios module provides an interface to the POSIX for tty I/O control. It is only available for Unix system. To use the termios module, we should import it using − import termios All methods in this module, takes the file descriptor as an argument. There are some modules of the termios module, these are − Method termios.tcgetattr(fd) This method returns a list of tty attributes for the given file descriptor. The attributes are iflag, oflag, cflag, lflag, ispeed, ospeed, cc. Method termios.tcsetattr(fd, when, attributes) This method is used to set the attribute from the list of attributes. ... Read More

Python Function to Check UNIX Passwords

Arjun Thakur
Updated on 30-Jul-2019 22:30:23

525 Views

To verify UNIX password, we should use the crypt module. It has crypt(3) routine. It is basically one-way hash function based on the modified DES algorithm. To use the crypt module, we should import it using. import crypt Method crypt.crypt(word, salt) This method takes two arguments. The first one is the word and second one is salt. The word is basically the user password, which is given in the prompt. The salt is a random string. It is used to perturb the DES Algorithm in one of 4096 ways. The salt contains only Upper-case, Lower-case, Numeric values ... Read More

Access to the Group Database in Python

George John
Updated on 25-Jun-2020 14:03:37

206 Views

To access the UNIX group database, we should use the grp module. The shadow password database entries are like tuple like object.To use the grp module, we should import it using −import grpThe attributes of the grp database are −IndexAttribute & Description0gr_nameThe Name of the groups1gr_passwdThe Encrypted password for the group. (Generally empty)2gr_gidThe group id (Numeric)3gr_memA list of group usersIn the group object, the gid is an integer. The group name and the password are strings. The Member list is a list of strings.Some methods of this module are −Method grp.getgrgid(gid)This method will return group database entry from the given ... Read More

Access to the Shadow Password Database in Python

Chandu yadav
Updated on 30-Jul-2019 22:30:23

211 Views

To access the UNIX shadow password database, we should use the spwd module. We need enough privileges to access this file. The shadow password database entries are like tuple like object. To use the spwd module, we should import it using − import spwd The attributes of the shadow password database are − Index Attribute & Description 0 sp_nam The Login Name or the username of the user 1 sp_pwd The Encrypted password 2 sp_lstchg Date of last change 3 sp_min Minimal number of days ... Read More

Access to the Password Database in Python

Ankith Reddy
Updated on 25-Jun-2020 14:04:13

451 Views

To access the password database, we should use the pwd module. Using this module, we can access users account and password database. The password database entries are like tuple like object.To use the pwd module, we should import it using.import pwdThe attributes of the password database are −IndexAttribute & Description0pw_nameThe Login Name or the username of the user1pw_passwdThe Encrypted password2pw_uidNumeric ID for the user3pw_gidNumeric ID for the user’s group4pw_gecosName of the user and comment field5pw_dirHome directory of the user6pw_shellUser’s Command interpreter.Note − Generally, the pw_passwd holds the encrypted passwords. But in the new systems, they use the shadow password system. ... Read More

Advertisements