On Mon, Jul 22, 2002 at 10:07:32PM +0200, lasse wrote:
> Jag vill att outputen ska se up typ
> Uptime is now 2 days and system load is 00. 00. 00. And we got 4 Users
Här ett exempel på hur du kan misshandla uptime ... skriptet tar hänsyn
till om maskinen i fråga har varit upp mindre än 24h.
--8<--
#!/bin/sh
UPTIME=`uptime`
if [[ `echo $UPTIME | grep days` ]]; then
MSG=`echo $UPTIME | awk '{ printf("Uptime is now %s days and %s with system load %s %s %s, and we got %s user(s) currently logged in.\n", $3, $5, $10, $11, $12, $6) }'`
else
MSG=`echo $UPTIME | awk '{ printf("Uptime is now %s with system load %s %s %s, and we got %s user(s) currently logged in.\n", $3, $8, $9, $10, $4) }'`
fi
echo $MSG
-->8--
Skriptet använder inga BASH-specifika kommandon, utan fungerar finfint i
BournShell och KornShell (på Solaris).
mvh
--
+-----------------------------------------------------------+
| Johan Björklund <the@whero.net> http://whero.net/ |
| PGP = 813B 014F C0FA B56C FA70 31DC 1C11 3A20 B02B C881 |
+-----------------------------------------------------------+
| Help me, I'm a prisoner in a Fortune cookie file!
+-------------------------------- ------ ----- ---- --- -- -
Attachment:
pgpxLH3RsU9_3.pgp
Description: PGP signature