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.

Get info from /proc/uptime

Old posts that have not been replied to for several years.
Locked
w
woffer

Post by woffer »

Anyone know the formula for transforming the info in /proc/uptime to weeks days hours mins and secs (want it to say the uptime nice to the channel on when triggered. like 1week 2days 34min and so on .. not bot uptime .. but machine uptime) ?

<font size=-1>[ This Message was edited by: woffer on 2001-11-08 16:06 ]</font>
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Look through scripts such as netbots.tcl.

There is an example of how to get the uptime information, through which a simple puhelp will help get it to it's destination.
w
woffer

Post by woffer »

Yea, i've looked there.. but i've only found scripts that gives the bots uptime or the machine uptime in only days.. so far.. will continue to look... =)
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

I think the first number is the number of seconds the system has been up. I don't know what the second number is.

Getting the time is easy:

Code: Select all

proc get_time {total} {
  set seconds [expr $total % 60]
  set total [expr $total / 60]
  set minutes [expr $total % 60]
  set total [expr $total / 60]
  set hours [expr $total % 24]
  set total [expr $total / 24]
  set days [expr $total % 365]
  set years [expr $total / 365]
  return [list $years $days $hours $minutes $seconds]
}
w
woffer

Post by woffer »

Thanks... but hehe
I found a better way.

proc get_time {} {
set total2 [lindex[exec /usr/bin/cat /proc/uptime] 0]
set total [lindex [split $total2 .] 0]
return [duration $total]
}
Locked