LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-19-2004, 06:03 PM   #1
dsheller
Member
 
Registered: Jan 2003
Posts: 56

Rep: Reputation: 15
Shelling df


Basically I want to be able to shell df and get what it returns from a cpp app, if there is an easier way to do that I am all ears.
 
Old 06-19-2004, 07:05 PM   #2
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
It looks like the way df works is via statfs(2). I would go this route.

If you still decide to parse the output of df, you probably want popen(3) to get its output. For more direct control, you could duplicate popen()'s functionality with fork(2), pipe(2), dup2(2), and execl(3).
 
Old 06-20-2004, 12:17 PM   #3
dsheller
Member
 
Registered: Jan 2003
Posts: 56

Original Poster
Rep: Reputation: 15
Thanks that works great! I got it to stuff all the info in a vector and its working fine.
 
Old 06-20-2004, 12:37 PM   #4
aluser
Member
 
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 43
excellent

for future reference, I figured the statfs() call out by doing "strace df". strace lists all the system calls a program makes, and their arguments. It's great for figuring out "how do I programmatically do what this unix utility is doing?"
 
Old 06-20-2004, 06:23 PM   #5
dsheller
Member
 
Registered: Jan 2003
Posts: 56

Original Poster
Rep: Reputation: 15
Ooh, thanks that will come in handy I am sure one day.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration