getting memory info from system
Howdy, I'm tearing through my O'Reilly books and the CPAN search trying to find a module or built-in function call that will let me get statistics back from the system regarding memory. I'm trying to find: 1) real memory bytes total 2) real memory bytes used 3) real memory bytes free As a secondary interest I'd like to do the same stats but for the swap file(s). Can anyone here point me in the right direction please? Thanks. Chris Hedemark - Hillsborough, NC http://yonderway.com
Re: getting memory info from system
Doesn't work on OpenBSD. - Original Message - From: <[EMAIL PROTECTED]> To: "Chris Hedemark" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Wednesday, June 20, 2001 12:05 AM Subject: Re: getting memory info from system > yeah just type : 'free' > > Ryan > > On Tue, 19 Jun 2001, Chris Hedemark wrote: > > > Howdy, > > > > I'm tearing through my O'Reilly books and the CPAN search trying to find a > > module or built-in function call that will let me get statistics back from > > the system regarding memory. I'm trying to find: > > > > 1) real memory bytes total > > 2) real memory bytes used > > 3) real memory bytes free > > > > As a secondary interest I'd like to do the same stats but for the swap > > file(s). > > > > Can anyone here point me in the right direction please? > > > > Thanks. > > > > Chris Hedemark - Hillsborough, NC > > http://yonderway.com > > > > >
Re: getting memory info from system
Clarification: I'm doing this on OpenBSD. If there is a portable function that will work across *NIX flavors that is preferable but if not I guess I need something BSD specific. Thanks. Chris Hedemark - Hillsborough, NC http://yonderway.com Original Message - From: "Chris Hedemark" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 19, 2001 11:45 AM Subject: getting memory info from system > Howdy, > > I'm tearing through my O'Reilly books and the CPAN search trying to find a > module or built-in function call that will let me get statistics back from > the system regarding memory. I'm trying to find: > > 1) real memory bytes total > 2) real memory bytes used > 3) real memory bytes free > > As a secondary interest I'd like to do the same stats but for the swap > file(s). > > Can anyone here point me in the right direction please? > > Thanks. > > Chris Hedemark - Hillsborough, NC > http://yonderway.com > >
Re: file size
#!/usr/bin/perl # # Name:statdemo.pl # Author: Chris Hedemark <[EMAIL PROTECTED]> # Purpose: Demonstrate use of the stat() function. # Usage:perl statdemo.pl filename1 filename2 filename3... if (!@ARGV) { die "No arguments!\n"; } for ($i = 0; $i < @ARGV.""; ++$i) { if (-e $ARGV[$i]) { @fileinfo = stat($ARGV[$i]); print "Size of $ARGV[$i]: $fileinfo[7]\n"; } else { print "File $ARGV[$i] does not exist!\n"; } # Sample output: # # [chrish@shrimp perl]$ perl statdemo.pl bogus.file /boot/vmlinuz-2.2.16-3smp /etc/smb.conf /bin/mail # File bogus.file does not exist! # Size of /boot/vmlinuz-2.2.16-3smp: 648343 # Size of /etc/smb.conf: 10846 # Size of /bin/mail: 62384 # [chrish@shrimp perl]$ - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 21, 2001 6:18 AM Subject: file size > Hi, > > I would like to know if with a perl script you can get the size of a file ? > I need to get all the size of 250 files on 250 computers ... > > thanx >
Re: SUB ?
Yes, "sub" denotes a "subroutine". Syntax: sub name { command; command; command; } You call it like this: name(arg1,arg2); I highly recommend picking up a copy of "Learning Perl" which explains this in great detail. - Original Message - From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, June 21, 2001 10:00 AM Subject: SUB ? > Hi All, > > Can you tell me what this sub is. Is it sub routine ? > > Regards, > Elaine. > > > local(@acc_fields) = @_; > return(-810) if ( $acc_fields[0] == 0 || $acc_fields[0] eq '' ); > return(-811) if ( $acc_fields[1] eq "" ); > return(-812) if ( $acc_fields[2] eq "" ); > return(-813) if ( $acc_fields[7] < 0 ); > $acc_fields[8] = &get_date if ( $acc_fields[8] eq '' ); > > return(&send_ddc("tdilc5110b000","accum_cycle_count",@acc_fields)); > } > > sub ilc_cycle_counting > { > # @icc_fields are: > #0 - Cycle Counting Order > #1 - Warehouse > #2 - Location > #3 - Item Code > #4 - Container > # 5 - Lot Code > # 6 - Storage Unit > # 7 - Counted Inventory > #8 - Counting Date > > local(@icc_fields) = @_; > return(-810) if ( $icc_fields[0] == 0 || $icc_fields[0] eq '' ); > return(-811) if ( $icc_fields[1] eq "" ); > return(-812) if ( $icc_fields[2] eq "" ); > return(-813) if ( $icc_fields[7] < 0 ); > $icc_fields[8] = &get_date if ( $icc_fields[8] eq '' ); > > return(&send_ddc("tdilc5110b000","ilc_cycle_counting",@icc_fields)); > } > > # > -- --- > # called from ccount form to ensure wharehouse/order combination is valid > # > -- --- > > sub validate_whse_order > { > local($whse) = $_[0]; > local($corder) = $_[1]; > > return if ($whse eq ""); > return if ($corder eq ""); > > &display_status("Checking Order..."); > $select = "SQL$;VALCCORDER$;${company}$;N$;$;${corder}$;${whse}"; > return(&send_dc($select)); > } > > sub item_loc_on_ccorder > { > my($item,$loc,$corder) = @_; > > return if ($item eq ""); > return if ($loc eq ""); > return if ($corder eq ""); > > &display_status("Checking Item/Loc..."); > $select = "SQL$;ITMLOCCCORDER$;${company}$;N$;$;${corder}$;${item}$; > ${loc}"; > return(&send_dc($select)); > } # item_loc_on_ccorder > > sub get_ccorder_item_date > { > my($item,$location,$order,$warehouse,$lot) = @_; > > &display_status("Checking Item/Loc..."); > $select = "SQL$;CCORDERDATE$;${company}$;N$;$;${order}$;${warehouse}$; > ${location}$;${item}$;${lot}"; > ### return(&send_dc($select)); > $return = &send_dc($select); > ($cdate) = split($;,$err_msgs[0]); > if ( $return == 1 ) > { > return 0; > } > else > { > return 1; > } > } # > > 1; > >
Re: to delete a file
#!/usr/bin/perl # # Name:unlinkdemo.pl # Author: Chris Hedemark <[EMAIL PROTECTED]> # Purpose: Demonstrate use of the unlink function. if (!@ARGV) { die "No arguments!\n"; } for ($i = 0; $i < @ARGV.""; ++$i) { if (-e $ARGV[$i]) { unlink ("$ARGV[$i]"); } else { print "File $ARGV[$i] does not exist!\n"; } } - Original Message - From: "Stéphane JEAN BAPTISTE" <[EMAIL PROTECTED]> To: "PERL" <[EMAIL PROTECTED]> Sent: Thursday, June 21, 2001 10:03 AM Subject: to delete a file How can I delete a file ? thanks
Re: to delete a file
This will work on UNIX but I recommend against this because it is not portable to other platforms, and there inefficiency in this in that it is not native perl. I recommend using the unlink command in perl which will be portable across platforms and for a large number of files/servers it will run faster with less resource overhead. - Original Message - From: "n6tadam" <[EMAIL PROTECTED]> To: "Stéphane JEAN BAPTISTE" <[EMAIL PROTECTED]>; "PERL" <[EMAIL PROTECTED]> Sent: Thursday, June 21, 2001 10:04 AM Subject: Re: to delete a file > Hi, > > Usually, one uses the following command (from the shell prompt) > > "rm /path/to/file/filename" > > To supress the confirmation message, use: > > "rm -f /path/to/file/filename" > > To delete recursively (i.e. a directory), and make it verbose to the screen: > > rm -rfv /path/to/directory > > Does that help. > > Of course, from a perl script, you can either use: > > system("/bin/rm -f /path/to/filename"); > > or > > `rm -f filename` > > I hope that helps, > Regards, > > Thomas Adam (VI form student) > Linux Co-ordinator at the Purbeck School (Network Support) > Wareham, > Dorset, > UK > - Original Message - > From: Stéphane JEAN BAPTISTE <[EMAIL PROTECTED]> > To: PERL <[EMAIL PROTECTED]> > Sent: Thursday, June 21, 2001 3:03 PM > Subject: to delete a file > > > > > How can I delete a file ? > > thanks > > > > > Please note that the content of this message is confidential between the original sender and the intended recipient(s) of the message. If you are not an intended recipient and/or have received this message in error, kindly disregard the content of the message and return it to the original sender. > > If you have any complaints about this message please reply to: >[EMAIL PROTECTED] > > The Purbeck School E-Mail server running: >users.purbeck.dorset.sch.uk >
Re: Perl programming
Jaya please have mercy. My mailbox is about to burst. Before asking any more questions, you really ought to do some reading for yourself. I highly recommend the book "Learning Perl". Spend one hour per week and in about a week and a half you'll be able to follow along pretty well. Chris Hedemark - Hillsborough, NC http://yonderway.com - Original Message - From: "jaya kumaran" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, June 22, 2001 6:31 AM Subject: Perl programming > > Hi all, > >Is perl progamming on windows is different from unix. >Will i be able to run the perl script on both window and unix without any modification?? > > > Thanks in advance, > jaya k > > _ > Get Free Fast Easy email from indiya.com: SIGNUP NOW : http://www.indiya.com >
Re: Kernel Messages
http://www.perl.com/pub/doc/manual/html/lib/Sys/Syslog.html - Original Message - From: "Ryan Gralinski" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Saturday, June 23, 2001 8:07 AM Subject: Kernel Messages > How do i use perl to log to syslog ? > as a kernel message that comes out in syslog, and console.. > > Ryan > >
RE: Unsubscribing
Wow... certainly a lot of hoops to jump through to get off the list (no, I am not one of those who wishes to leave). Would be nice if we went to a system less antiquated and unnecessarily complicated. Also it would be nice to have uns*b instructions in the footer of every outbound message. Of course this means uns*bbing needs to get simpler. Chris Hedemark - Hillsborough, NC http://yonderway.com - Original Message - From: "Lucy" <[EMAIL PROTECTED]> To: "Cochrane, Paul" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Tuesday, June 26, 2001 6:58 AM Subject: Re: Unsubscribing > I have no idea why everyone is finding it so hard to unsubscribe. :) > I have tried it once again, and had no problems. > > 1) send email to > > [EMAIL PROTECTED] > > (yes, substituting "username-somewhere.com" from your real address) > > =) > > 2) you will receive an email with the subject "confirm unsubscribe from [EMAIL PROTECTED]" > > 3) send a blank email to the *address specified* in the email. > The relevant part of the email should look something like this:- > > > To confirm that you would like > >[EMAIL PROTECTED] > > removed from the beginners-cgi mailing list, please send an empty reply > to this address: > > beginners-cgi-uc.993552577.jegmnjpgpmjmbbpgidod-username=somewhere.com@perl. org > > > > It should also be the address in the "Reply-to" header, make sure your mail client uses this > "reply-to" header or alternately paste the email adress into your mail client. > There is a clickable "mailto" link if your client utilises html links too. > > Send a blank email to this address. > > 4) Receive the email entitled "GOODBYE from [EMAIL PROTECTED]" and you are unsubscribed. > > Can anyone still having problems please point out at which stage the unsubscribe process is going wrong for you? > > We'll try and get it sorted once and for all. ;-) > With more detail of where the problem is, perhaps we can change the info on learn.perl.org > or make the instructions in the "WELCOME to [EMAIL PROTECTED]" email clearer. > > > > --lucy > > > > > Me too. Please will someone remove me from this list? > > > > -Original Message- > > From: Derek Harding [mailto:[EMAIL PROTECTED]] > > Sent: 26 June 2001 10:26 > > To: [EMAIL PROTECTED] > > Subject: Unsubscribing > > > > > > In company with Bernhard and others I am having immense problems getting > > myself unsubscribed. > > > > On one hand I get automated mail telling me to reply, which I duly do, then > > it tells me I'm not subscribed but clearly, I am! > > > > Dare I suggest that this part of the service is broken? > > > > PLEASE take me off the list!!! > > > > -- > > Best wishes, > > Derek Harding, (BA MIAP) > > ICT & Network Manager > > [EMAIL PROTECTED] > > > -- > .-"""-. > /* * * *\ > :_.-:`:-._; [EMAIL PROTECTED] > (_) http://triffid.org > _\|/(_)\|/ >
Re: chomp ?
I'm usually the last person to say this (in fact I think it is the first time I've ever ever felt the need to say this) but "RTFM". If you can't find this on your own you are either too lazy to warrant help, or too dumb to absorb the help that is given. You Wrote: -- What is chomp ? tks ___
Re: chomp ?
OK maybe it was harsh. I apologize if it was too rough. I'm sorta new to /this/ list and as you probably know by now, I usually answer questions with example code. Partially to give the best possible answer, and partially to give me practice. But this question just smacked of someone being too lazy to at least /try/ and figure it out for themselves. If the question were more like "I've read the man page on chomp() and can't get it working right. Can someone give me an example of chomp() being used in a real program to help clear it up for me?" Then I probably would have given my more typical answer. Chris Hedemark - Hillsborough, NC http://yonderway.com - Original Message - From: "Ronald J. Yacketta" <[EMAIL PROTECTED]> To: "Chris Hedemark" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Tuesday, June 26, 2001 10:35 AM Subject: RE: chomp ? > OUCH! > > some people just need a gentle slap to get them going.. kind of like a > newborn ;) slap them on the arse to get them breathing. > > This was overkill ;) more like a boot to the skull! > > take it easy bubba :) > > > > I'm usually the last person to say this (in fact I think it is > > the first time I've ever ever felt the need to say this) but "RTFM". > > > > If you can't find this on your own you are either too lazy to > > warrant help, or too dumb to absorb the help that is given. >
Re: whoami?
There are some reserved variables that you should keep in mind for this purpose (taken from "Perl in a Nutshell"): $> $EFFECTIVE_USER_ID $EUID The effective UID of the current process. $< $REAL_USER_ID $UID The real UID of the current process. You can couple this with the function getpwuid() to return the actual user name. There may be a more effective way to do this, but here is an example script: #!/usr/bin/perl # # Name: getpwuid.pl # Author: Chris Hedemark <[EMAIL PROTECTED]> # License: BSD # Purpose: Demonstrate the getpwuid() function # $< is a reserved variable for the current real UID of this process. $uname = getpwuid($<); print "$uname is the real user name running this process.\n"; # $> is a reserved variable for the current effective UID of this process. $uname = getpwuid($>); print "$uname is the effective user name running this process.\n"; - Original Message - From: "Matija Papec" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 26, 2001 8:38 AM Subject: whoami? > > Greetings, > > is there a more elegant way to find out who is running a script? %ENV is > not reliable and it doesn't contain USER when booting the system, and > "whoami" is external command(yuck :) ) tnx! > > > > -- > Matija >
Re: Checking Free Disk Space in Win32
# From "Perl for System Administration" use Win32::AdminMisc; ($total,$free) = Win32::AdminMisc::GetDriveSpace("c:\\"); print "$free bytes of $total bytes free\n"; # Good luck, hope that helps! # -Chris - Original Message - From: "Aaron Petry" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, June 26, 2001 1:45 PM Subject: Checking Free Disk Space in Win32 > I've been looking for a way to check the free disk space on a drive in > Win32 all morning. I could use a command input operator like `dir c:` and > take the return value, but that gives me a whole file listing, and I'm not > thrilled with breaking that up to find the "x bytes free" line. I can't > find a switch for the dir command in Win 2k to show just the free space, > and if I search for a file that won't be there I just get "File Not > Found." I haven't found anything in any modules that I have, and I thought > that someone here would know how to get the free disk space in a nice > way. Does anyone have any suggestions? >
Re: Checking Free Disk Space in Win32
BTW I just recently bought this book ("Perl for System Administration", the otter book from O'Reilly). You really otter get it (duck). It's got tons of good stuff for managing Macs, Win32 systems, *NIX, etc. and goes about explaining how to do things on each of the different platforms. Chris Hedemark - Hillsborough, NC http://yonderway.com - Original Message - From: "Chris Hedemark" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; "Aaron Petry" <[EMAIL PROTECTED]> Sent: Tuesday, June 26, 2001 1:48 PM Subject: Re: Checking Free Disk Space in Win32 > # From "Perl for System Administration" > use Win32::AdminMisc; > > ($total,$free) = Win32::AdminMisc::GetDriveSpace("c:\\"); > > print "$free bytes of $total bytes free\n"; > > # Good luck, hope that helps! > # -Chris > > - Original Message - > From: "Aaron Petry" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Tuesday, June 26, 2001 1:45 PM > Subject: Checking Free Disk Space in Win32 > > > > I've been looking for a way to check the free disk space on a drive in > > Win32 all morning. I could use a command input operator like `dir c:` and > > take the return value, but that gives me a whole file listing, and I'm not > > thrilled with breaking that up to find the "x bytes free" line. I can't > > find a switch for the dir command in Win 2k to show just the free space, > > and if I search for a file that won't be there I just get "File Not > > Found." I haven't found anything in any modules that I have, and I > thought > > that someone here would know how to get the free disk space in a nice > > way. Does anyone have any suggestions? > > > >
Re: Suggestions?
Someone recommended a SAMS book that will teach you perl in 21 days. Get the O'Reilly "Llama" book ("Learning Perl") and spend about an hour a day to finish in less than a week and a half. There are a few other O'Reilly titles I really like: "Perl in a Nutshell" - great reference "Perl for System Administration" - If you are a sysadmin or webmaster this is a must-have. I want to get "Programming Perl" (the Camel book) as well as their Win32 book (even though most of my work is currently in UNIX). Chris Hedemark - Hillsborough, NC http://yonderway.com - Original Message - From: "Bill Pierson" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, June 27, 2001 11:57 AM Subject: Suggestions? Greetings all - I realize this is a very broad question, however any suggestions would be appreciated. I'm looking to purchase good learning tools about programming in PERL. I've been programming with it for several years, but I've never truly learned the basics - just looked at other code and learned from that. Specifically I'd like to learn from "ground zero" about variables, hashes, etc. as well as MySQL connectivity. I'd like to find something that is concise - I have several projects that I'll be working on in the very near future, and fine-tuning my knowledge would be of great benefit. Again, any suggestions will be appreciated.