Tony Heal wrote:
Ok here is why I ask.

I can write a shell script to do most things, but perl can do more so I am 
learning perl. To get file stats in bash is
simply combine ls, grep and cut to get whatever I want. But perl has a function 
to do this called stats()

Rather than use stats() and have to figure out how that works I could get what 
I want by using bash and simply wrapping
that in the system() command in perl, but that would not really be teaching me 
anything.

So instead I figured out how to use stats().
Now as for getting partition info I wanted to know if perl had a way of getting 
the info. From what I can tell the
simply answer is no. There are however several modules on CPAN that have been 
written to get the info required, but it
appears that all of them are simply wrappers for the df command which I can do 
on my own, and at least bring my perl up
another minor notch in the doing.

My thanks to Lawrence Statton XE2/N1GAK [EMAIL PROTECTED] for the link to CPAN
http://search.cpan.org/search?query=disk+space+DF&mode=all
Thank you Tom for the effort

By the way, since we are all on the beginners perl list, there is no reason to 
CC me on the emails. If you send it to
the list I will get it. If you CC me I will get the reply twice.

Thanks again

Tony

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Phoenix
Sent: Monday, February 05, 2007 12:43 PM
To: [EMAIL PROTECTED]
Cc: beginners@perl.org
Subject: Re: stats on partitions

On 2/5/07, Tony Heal <[EMAIL PROTECTED]> wrote:

OK, so bash is the shell I am using and the df utility is a
standard Xnix command. My question is, is there a perl way
of getting the stats on partitions without having to shell out
using system() or exec()?
Well, this is not unlike asking if there's a way to get a hot meatloaf
out of the oven without having to put on oven gloves. But yes, you
could write Perl code (perhaps with a little XS to handle a system
call or two; I'm not sure) to do what df does. It probably won't be as
fast, secure, portable, or easy to write as using system() to invoke
df, but on the plus side you'll get to debug it all yourself. And
since it has to run with special privileges, you might even break
something important along the way, or open a security hole without
realizing it.

Is there some reason you can't use oven gloves? I mean df?

Cheers!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




I have been a system administrator of *nix systems, using perl, for quite sometime now. I have found that in most of my scripts I use a combination of perl and system commands to get the job done. In most cases this is much quicker in easier.

It's true that a lot of what I've written possibly could have been done which just a bash script. I find that where the advantage to using a mixture is in the control perl gives me through regular expressions, hashes, etc. I can do things faster and easier by using system commands to get the information and using perl to handle the information.

I think you'll find that there are somethings you can have perl do instead of using system commands that are great for learning and in some ways better and then there are somethings that just aren't worth it, making system commands a helpful friend. I think df is one of these. For instance, why install and use a module that does the same thing as df when you can just use df. Plus you can pretty much guarantee that your code will be more protable. A system is more likely to have df than some module on CPAN.

That all being said, I can certainly understand you wanting to give it a try in perl for the sake of learning.

Good luck in your learning!

Chad

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to