[bcn-pm] Manejar salidas del sistema.
Pere Benavent
pbenaventagmail.com
Dij Mar 9 08:15:19 PST 2006
Fes-li una mirada a:
## Title: df-sum
##
## Submitter: Art Mulder
## Submitter Email: amulderairus.rri.on.ca
##
## A short script that runs "df" and totals up the results.
## print results as: Hostname, Megabytes Avail, Megabytes Used
##
## -- Art Mulder, Jun2001
##
## - 4.Mar.2002 - tweak the awk line to elimnate the need for grep.
## submitted by Carl.Marinoacoutts.com
##
## Example Output:
## hostname.nowhere.com 37038 MB, 16058 MB used
hostnm=`hostname`
# We need to allow for different versions of 'df' on differt Unix OS's
ostype=`/bin/uname`
#echo $ostype
if [ $ostype = "Linux" -o $ostype = "SunOS" ]; then
dfbinary="/bin/df -kl"
elif [ $ostype = "IRIX64" ]; then ## Newer SGI's. Irix 6.5 at least
dfbinary="/bin/df -Pkl"
else ## use the GNU version of df
dfbinary="/irus/bin/df"
fi
##disksum=`$dfbinary | grep dev | awk '{t += $2; u += $3} \
disksum=`$dfbinary | awk '/dev/ {t += $2; u += $3} \
END { printf("%d MB, %d MB used",t/1024,u/1024) }'`
echo $hostnm $disksum
# -- END --
Fale, no és perl, però s'hi pot adaptar.... hi han més a
http://www.sun.com/bigadmin/home/
Pere Benavent
> Have a nice day ;-)
> TooManySecrets
>
> ============================
> Nine megs for the secretaries fair,
> Seven megs for the hackers scarce,
> Five megs for the grads in smoky lairs,
> Three megs for system source;
>
> One disk to rule them all,
> One disk to bind them,
> One disk to hold the files
> And in the darkness grind 'em.
> ============================
> _______________________________________________
> llista dels Barcelona-pm
> Barcelona-pmapm.org
> http://mail.pm.org/mailman/listinfo/barcelona-pm
> BCN Perl Mongers: http://barcelona.pm.org
>
--
"El hombre es la medida de todas las cosas"
Protágoras
http://www.benavent.org
Més informació de la llista de correu Barcelona-pm