manishjain2792 Mount2 20130711-132947


Posted:

Problem:

Write a python program which gives the same output as while typing "mount" command in the terminal.

Code Snippet

1. #!/usr/bin/env python
2. file=open("/proc/mounts") # open file named "/proc/mounts
3. print file.read() # read that file and print it
4. file.close() # it closes that file after reading it

Explanation

At first open the file .proc/mounts using "open" command. Then i used "file.read()" command to read the file and use print to print the content of that file. At last i closed that file using "file.close()" command.

The code is here

How to execute

1. $ python mount.py

or

1. $ chmod +x mount.py
2. $ ./mount.py
Contents © 2013 dgplug - Powered by Nikola
Share
UA-42392315-1