gpt4 book ai didi

linux - Bash - 硬件信息(脚本中的西类牙语文本)

转载 作者:太空宇宙 更新时间:2023-11-04 11:22:39 25 4
gpt4 key购买 nike

#!/bin/bash

function Procesador()
{

# Determinando la Velocidad del Procesador
CPUMHz=`cat /var/log/dmesg | grep "MHz processor" | cut -d " " -f07 | sed 's/[.].*//'`
if [ "$CPUMHz" -ge "133" ];
then
if [ "$CPUMHz" -ge "1032" ];
then
let "CPUGHz"=$CPUMHz/1000
echo "$CPUGHz GHz"
else
echo "$CPUMHz Mhz"
fi
else
echo "Menos de 133 Mhz de Procesador"
fi


}

function MemoriaRAM()
{

# Determinando la Cantidad De memoria RAM
RAM_Kb=`grep MemTotal /proc/meminfo | awk '{print $2}'`
if [[ "$RAM_Kb" -lt "1048576" ]];
then
let RAM_MB=$RAM_Kb/1024
echo "$RAM_MB MB"
elif [[ "$RAM_Kb" -gt "1048576" ]];
then
let "RAMGb"=$RAM_Kb/1024
RAMGb=`echo "scale=1; 1*($RAM_Kb/1024000)" | bc -l`
echo "$RAMGb" "GB"
else
echo "Menos de 16 MB RAM"
fi

}

function Video()
{
# Determinando Tarjeta De Video
# Determinando Memoria De Video
vcard=`lspci -v | grep "VGA" | cut -d " " -f05`
MDV=`MB_DE_VIDEO`
echo "$MDV"
}

function MB_DE_VIDEO()
{
# Determinando Memoria De Video
vcard=$(lspci -v | grep "VGA" | cut -d " " -f05)
vidsize=$(lspci -v -s `lspci | awk '/VGA/{print $1}'` | sed -n '/Memory.*, prefetchable/s/.*\[size=\([^]]\+\)M\]/\1/p')
Conviduso=$(lspci -nnk | grep -i vga -A3 | grep 'in use' | cut -d " " -f05)
if [ "$vidsize" -ge "8" ]
then
echo "Tarjeta De Video : $vcard "
echo "Memoria De Video : $vidsize MB"

if [ "$Conviduso" = "" ]; then
echo "Control De Video : Desconocido"
fi
if [ "$Conviduso" = "nvidia" ]; then
echo "Control De Video : $Conviduso (Privativo)"
fi

if [ "$Conviduso" = "nv" ]; then
echo "Control De Video : $Conviduso (Libre)"
fi

if [ "$Conviduso" = "nouveau" ]; then
echo "Control De Video : $Conviduso (Libre)"
fi

if [ "$Conviduso" = "radeon" ]; then
echo "Control De Video : $Conviduso (Libre)"
fi

if [ "$Conviduso" = "fglrx" ]; then
echo "Control De Video : $Conviduso (Privativo)"
fi

if [ "$Conviduso" = "fglrx_pci" ]; then
echo "Control De Video : $Conviduso (Privativo)"
fi

if [ "$Conviduso" = "openchrome" ]; then
echo "Control De Video : $Conviduso (Libre)"
fi

if [ "$Conviduso" = "intel" ]; then
echo "Control De Video : $Conviduso (Libre)"
fi

support3d=$(glxinfo | grep "direct rendering: Yes" | cut -d " " -f03)
if [ $support3d = "Yes" ];
then
echo "Funcion De Video : Soporte 3D & Renderizado Directo"
else
echo "Funcion De Video : Sin Soporte 3D"
fi
else
echo "Menos de 8 MB de Video y sin Soporte 3D"
fi
}


function Arquitectura()
{

# Determinando la Arquitectura de la Maquina
arch=`uname -m`
if [ $arch = "i386" ]; then
echo "Sistema de 32 Bits / x86 "
elif [ $arch = "i486" ]; then
echo "Sistema de 32 Bits / x86 "
elif [ $arch = "i586" ]; then
echo "Sistema de 32 Bits / x86 "
elif [ $arch = "i686" ]; then
echo "Sistema de 32 Bits / x86 "
elif [ $arch = "x86_64" ]; then
echo "Sistema de 64 Bits / x86_64 "
else
echo "Architectura Desconocida"
fi


}

function CPUCache()
{

# Determinando la Cache del CPU
CpuCache=`awk -F':' '/^cache size/ { print $2 }' /proc/cpuinfo | uniq | cut -d " " -f02`
if [ "$CpuCache" -ge "1024" ]
then
if [ "$CpuCache" -ge "1024" ]
then
let "CpuCacheMB"=$CpuCache/1000
echo "$CpuCacheMB MB"
else
let "CpuCacheKB"=$CpuCache/1000
echo "$CpuCacheKB Kb"
fi
else
echo "Menos de 256 KB de Cache"
fi

}

clear
echo '#########################################################################'
echo '#### Script de Inukaze para Información del PC ####'
echo '#########################################################################'
echo ""
VDP=`Procesador`
echo "Tienes : `grep -c 'processor' /proc/cpuinfo | uniq` Procesador(es)"
echo "La Velocidad de la CPU es : $VDP "
CCache=`CPUCache`
echo "El Tamaño de Cache de la CPU es: $CCache"
echo "La Compañía de la CPU es :`awk -F':' '/^vendor_id/ { print $2 }' /proc/cpuinfo | uniq`"
ARCH=`Arquitectura`
echo "La Arquitectura Utilizada es: $ARCH "
echo "Módelo del CPU :`awk -F':' '/^model name/ { print $2 }' /proc/cpuinfo | uniq`"
echo ""
echo "#########################################################################"
echo "#### Información de la Memoria & Video ####"
echo "#########################################################################"
echo ""
MRAM=`MemoriaRAM`
echo "Memoria RAM : $MRAM "
echo ""
MVID=`Video`
echo "$MVID "
echo ""
echo "#########################################################################"

XORG=$(ps -A|grep Xorg|awk '{print $4}')
XFREE86=$(ps -A|grep XFree86|awk '{print $4}')

if [ "$XORG" = "Xorg" ]; then
if [ -f "$HOME"/.infohw ]; then
rm -rf "$HOME"/.infohw
fi
echo '#########################################################################' >> $HOME/.infohw
echo '#### Script de Inukaze para Informacion del PC ####' >> $HOME/.infohw
echo '#########################################################################' >> $HOME/.infohw
echo "" >> $HOME/.infohw
VDP=`Procesador`
echo "Tienes : `grep -c 'processor' /proc/cpuinfo | uniq` Procesador(es)" >> $HOME/.infohw
echo "La Velocidad de la CPU es : $VDP " >> $HOME/.infohw
CCache=`CPUCache`
echo "El Tamano de Cache de la CPU es: $CCache" >> $HOME/.infohw
echo "La Compania de la CPU es :`awk -F':' '/^vendor_id/ { print $2 }' /proc/cpuinfo | uniq`" >> $HOME/.infohw
ARCH=`Arquitectura`
echo "La Arquitectura Utilizada es: $ARCH " >> $HOME/.infohw
echo "Modelo del CPU :`awk -F':' '/^model name/ { print $2 }' /proc/cpuinfo | uniq`" >> $HOME/.infohw
echo "" >> $HOME/.infohw
echo "#########################################################################" >> $HOME/.infohw
echo "#### Informacion de la Memoria & Video ####" >> $HOME/.infohw
echo "#########################################################################" >> $HOME/.infohw
echo "" >> $HOME/.infohw
MRAM=`MemoriaRAM`
echo "Memoria RAM : $MRAM " >> $HOME/.infohw
echo "" >> $HOME/.infohw
MVID=`Video`
echo "$MVID " >> $HOME/.infohw
echo "" >> $HOME/.infohw
echo "#########################################################################" >> $HOME/.infohw
xmessage -file "$HOME/.infohw"
fi

if [ "$XFREE86" = "XFree86" ]; then
if [ -f "$HOME"/.infohw ]; then
rm -rf "$HOME"/.infohw
fi
echo '#########################################################################' >> $HOME/.infohw
echo '#### Script de Inukaze para Informacion del PC ####' >> $HOME/.infohw
echo '#########################################################################' >> $HOME/.infohw
echo "" >> $HOME/.infohw
VDP=`Procesador`
echo "Tienes : `grep -c 'processor' /proc/cpuinfo | uniq` Procesador(es)" >> $HOME/.infohw
echo "La Velocidad de la CPU es : $VDP " >> $HOME/.infohw
CCache=`CPUCache`
echo "El Tamano de Cache de la CPU es: $CCache" >> $HOME/.infohw
echo "La Compania de la CPU es :`awk -F':' '/^vendor_id/ { print $2 }' /proc/cpuinfo | uniq`" >> $HOME/.infohw
ARCH=`Arquitectura`
echo "La Arquitectura Utilizada es: $ARCH " >> $HOME/.infohw
echo "Modelo del CPU :`awk -F':' '/^model name/ { print $2 }' /proc/cpuinfo | uniq`" >> $HOME/.infohw
echo "" >> $HOME/.infohw
echo "#########################################################################" >> $HOME/.infohw
echo "#### Informacion de la Memoria & Video ####" >> $HOME/.infohw
echo "#########################################################################" >> $HOME/.infohw
echo "" >> $HOME/.infohw
MRAM=`MemoriaRAM`
echo "Memoria RAM : $MRAM " >> $HOME/.infohw
echo "" >> $HOME/.infohw
MVID=`Video`
echo "$MVID " >> $HOME/.infohw
echo "" >> $HOME/.infohw
echo "#########################################################################" >> $HOME/.infohw
xmessage -file "$HOME/.infohw"

fi

输出(Bash - 终端):

#########################################################################
#### Script de Inukaze para Información del PC ####
#########################################################################

Tienes : 2 Procesador(es)
La Velocidad de la CPU es : Menos de 133 Mhz de Procesador
El Tamaño de Cache de la CPU es: 1 MB
La Compañía de la CPU es : AuthenticAMD
La Arquitectura Utilizada es: Sistema de 32 Bits / x86
Módelo del CPU : AMD Athlon(tm) 64 X2 Dual Core Processor 6000+

#########################################################################
#### Información de la Memoria & Video ####
#########################################################################

Memoria RAM : 1.5 GB

Tarjeta De Video : NVIDIA
Memoria De Video : 256 MB
Control De Video : nvidia (Privativo) # Video Driver In Use
Funcion De Video : Soporte 3D & Renderizado Directo

#########################################################################

我需要零件方面的帮助:

“Control de Video”:本次 session 中使用的驱动程序(视频驱动程序)

“La Velocidad de la CPU es”:我需要另一件事,任何用户都可以阅读,以获得处理器的真实总速度

注意:如果您收到有关“/var/log/dmesg”的错误消息,您需要权限您可以使用“sudo chmod a+o+rw+x/var/log/dmesg”在终端中创建它。我需要另一件事不需要修改文件系统。

我真的想要这个脚本在每个发行版中都能正常工作我正在使用 Linux Mint 13 MAYA。

有人可以帮助我编写脚本吗?

最佳答案

代替

if [ "$RAM_Kb" -ge "1024" ];
then
let RAM_MB=$RAM_Kb/1024
echo "$RAM_MB MB"
elif [ "$RAM_Kb" -gt "102400" ];
then
let "RAMGb"=$RAM_Kb/102400 #/8
RAMGb=`echo "scale=1; 1*($RAM_Kb/1024000)" | bc -l`
echo "$RAMGb" "GB"
fi

尝试

if [ "$RAM_Kb" -gt "102400" ]
then
let "RAMGb"=$RAM_Kb/102400 #/8
RAMGb=`echo "scale=1; 1*($RAM_Kb/1024000)" | bc -l`
echo "$RAMGb" "GB"
elif [ "$RAM_Kb" -ge "1024" ];;
then
let RAM_MB=$RAM_Kb/1024
echo "$RAM_MB MB"

fi

因为 GB 总是大于 MB 并且您永远不会到达 else 分支。

关于linux - Bash - 硬件信息(脚本中的西类牙语文本),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17119230/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com