Skip to content

Files

Latest commit

 

History

History

Linux command in Python

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Working with Linux commands in Python script/ Utilities for running commands

Description:

The commands module contains wrapper functions for os.popen() which take a system command as a string and return any output generated by the command and, optionally, the exit status.

The subprocess module provides more powerful facilities for spawning new processes and retrieving their results. Using the subprocess module is preferable to using the commands module.

Deprecated since version 2.6:

The commands module has been removed in Python 3. Use the subprocess module instead.

Documentation to read:

commands module:

import commands

output = commands.getoutput('ls')
print(output)

num = output.count('d')
print("Number: ", num)

Programming languages and frameworks

Python

IDE

Vim

Author

Doston Hamrakulov

Software Engineer, Web Developer, Freelancer

Enjoy open-source community