The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM
Home Forums Register Rules & FAQ Members List Arcade Search Today's Posts Mark Forums Read


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!


Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-07-2008
Registered User
 

Join Date: May 2008
Posts: 4
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Arrow Please help me..

I am trying to get the output for memory information on Linux box.

Here is the cmd I ran on linux

free
output
-------
total used free
Mem: 122222 55500 66720


I need the out put like below..It is more helpful if any one can write this PERL..

Memory (MB)
total used(%) free(%)

12222 5550(47) 6672(53)


here is my sample.sh script that i used for this..

memory=$(free | awk '/Mem:/{print $2}')
usedmem=$(free | awk '/Mem:/{print $3}')
freemem=$(free | awk '/Mem:/{print $4}')
(freepct=(freemem*100)/memory))
((usedpct=100-freepct))
print "\n\n"
print " total used(%) free(%)\n"
printf "%5.0f %5.0f(%3.0f) %5.0f(%3.0f) ",$memory ,$usedmem ,$usedpct ,$freemem ,$freepct

I am getting some syntax error by running this. can you please help me to get the output(red colored) like the above either in PERL(preferred) or shell script..

I am waiting for you responses .......
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-11-2008
Registered User
 

Join Date: May 2008
Posts: 4
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
Smile Urgent Help needed..

Can any one give me brief ideas..... regarding this script.. Thanks in advance..
Reply With Quote
  #3 (permalink)  
Old 05-12-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 2,203
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Stumble this Post!Spurl this Post!
You can't do floating-point arithmetic in the shell, it only supports integer calculations.

The parentheses in your script are syntax errors, but given the above, taking them out doesn't help much, of course.

This looks suspiciously like something somebody else posted recently. Is this homework for a course? How to store values into variable in perl

Last edited by Neo : 05-12-2008 at 07:14 AM. Reason: edited.... removed sarcasm.
Reply With Quote
Google UNIX.COM
Reply



Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 06:16 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger

Search Engine Optimization by vBSEO 3.1.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102