473,413 Members | 2,056 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

how to parse system functions output

Dear all,

I want to parse the system functions output
but I couldn't do it. Kindly assist me in this
task.

eg) bytesused = os.system('du -sh /Users/enmail')
if I print this bytesused variable the output of
bytesused variable is the below

14M /Users/enmail
0

Now From this Output I want only '14M" I cannot split
this output by space. If anyone know regarding this
mail me ASAP

regards
Prabahar
__________________________________________________ ______________________
Yahoo! India Matrimony: Find your life partner online
Go to: http://yahoo.shaadi.com/india-matrimony
Jul 18 '05 #1
2 1847
praba kar wrote:
eg) bytesused = os.system('du -sh /Users/enmail')
if I print this bytesused variable the output of
bytesused variable is the below

14M /Users/enmail
0
It's unlikely this is the contents of "bytesused",
because os.system() does not return the output
of the program that is run, it returns only the
exit value. (See the doc.) The "14M ..." part
is actually being printed by the "du" command
as it runs. "bytesused" contains only the "0"
that you show above.
Now From this Output I want only '14M" I cannot split
this output by space. If anyone know regarding this
mail me ASAP


You are looking for either os.popen() or the newer,
more flexible "subprocess" module (available in
Python 2.4). Again, check the docs for details and
examples for both of these.

Basically you would do this:

result = os.popen('du -sh /Users/enmail').read()
# now parse result...

-Peter
Jul 18 '05 #2
Or if you run 2.4 you can use subprocess

Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Xah Lee | last post by:
Python Doc Problem Example: os.system Xah Lee, 2005-09 today i'm trying to use Python to call shell commands. e.g. in Perl something like output=qx(ls) in Python i quickly located the...
22
by: Illya Havsiyevych | last post by:
Hello How easily parse VB/VBA code by VB/VBA code ? Is any ready solutions ? Thank's, illya
19
by: Johnny Google | last post by:
Here is an example of the type of data from a file I will have: Apple,4322,3435,4653,6543,4652 Banana,6934,5423,6753,6531 Carrot,3454,4534,3434,1111,9120,5453 Cheese,4411,5522,6622,6641 The...
5
by: Adam Klobukowski | last post by:
Hello I need to convert some strings int doubles. Unfortunetly strings do not follow my country culture standarts (we use , to separate decimal from fraction, but strings use . there etc.). ...
14
by: Rob Meade | last post by:
Hi all, I'm working on a project where there are just under 1300 course files, these are HTML files - my problem is that I need to do more with the content of these pages - and the thought of...
10
by: Michael B. Trausch | last post by:
Alright... I am attempting to find a way to parse ANSI text from a telnet application. However, I am experiencing a bit of trouble. What I want to do is have all ANSI sequences _removed_ from...
4
by: yinglcs | last post by:
Hi, I use os.system() to execute a system command in python. Can you please tell me how can I parse (in python) the output of the os.system() ? Thank you.
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.