This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

convert mb into gb

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
T
TaRgEt
Voice
Posts: 4
Joined: Tue Sep 27, 2005 3:24 pm

convert mb into gb

Post by TaRgEt »

i hav vnstat running on my eggy n one thing i've neva been able to find is a script to convert the mb into gb on the eggy my script is:

Code: Select all

bind pub -|- !vnstat vnstat

set slavename "00"

proc vnstat {nick uhost hand chan text} {
global slavename
if {([string match $slavename [string toupper [lindex $text 0]]]) || ([string match [string toupper [lindex $text 0]] ""])} {
      set date [clock format [clock seconds] -format "%b '%y" -gmt 0]
      set month [lindex [split "[exec vnstat -m]" "\n"] end-2]
      set mb [lrange $month end-1 end-1]
      putserv "PRIVMSG $chan :During \002$date\002 we have used $mb "
  }
}
and output is:

Code: Select all

During Feb '06 we have used 3,535 MB
if someone could edit my script so it converts the MB into GB it would be greatly appreicated
Last edited by TaRgEt on Thu Feb 02, 2006 8:43 am, edited 1 time in total.
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

Code: Select all

[expr $mb / 1024.]
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
T
TaRgEt
Voice
Posts: 4
Joined: Tue Sep 27, 2005 3:24 pm

Post by TaRgEt »

i've tried it demond but that just won't work :(
User avatar
demond
Revered One
Posts: 3073
Joined: Sat Jun 12, 2004 9:58 am
Location: San Francisco, CA
Contact:

Post by demond »

strip commas from $mb:

Code: Select all

set gb [expr [string map {, {}} $mb] / 1024.]
connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use

Code: Select all

 tag when posting logs, code
T
TaRgEt
Voice
Posts: 4
Joined: Tue Sep 27, 2005 3:24 pm

Post by TaRgEt »

works absolute perfect now demond

thx bud :)
Post Reply