Home    Forum    Search    FAQ    Register    Log in


Post new topic  Reply to topic 
Page 1 of 2
Goto page 1, 2  Next
 
Extraer Informacion Del Sistema Desde La Terminal
Author Message
Reply with quote   Download Post  
Post Extraer Informacion Del Sistema Desde La Terminal 
 
Hola, encontré un articulo en desdelinux llamado como-extraer-parametros-desde-el-terminal-aplicando-shell-scripting, muy interesante, donde dan varios ejemplos de como obtener información del sistema desde la terminal.

Saludos.
 



 
tincho - View user's profileSend private message 
Back to topPage bottom
Reply with quote   Download Post  
Post Re: Extraer Informacion Del Sistema Desde La Terminal 
 
Gracias por la info. Todo sea para mejorar nuestro conocimiento de Shell Script.
 




===================
Gambas Básico
"No es un bug, es una característica no documentada"
 
Shell - View user's profileSend private messageVisit poster's website 
Back to topPage bottom
Reply with quote   Download Post  
Post Re: Extraer Informacion Del Sistema Desde La Terminal 
 
En esta línea aquí tenéis un puñado de funcioncetas que devuelven información del sistema. Las usamos en el curro para un inventario on-line de las máquinas de la empresa.
Desarrollado por mi Padawan. Las colocáis en un módulo y ¡Ala, a informarse!    
Public Function Distro() As String 'devuelve la distribución instalada xmi
  Dim sDis As String
  Shell " lsb_release -d | cut -d':' -f2" To sDis
   sDis = Trim(sDis)
  Return sDis
End

'*******************************************************************************

Public Function ArquitecturaSO() As String 'devuelve la Arquitecura del Sistema Operativo
  Return System.Architecture
End

'*******************************************************************************

Public Function ArquitecturaP() As String 'devuelve la Arquitecura del Procesador
    Dim sArqPro As String
    Exec ["uname", "-p"] To sArqPro 'Almacenamos la Arquitectura del Procesador
  Return Replace(sArqPro, "\n", "")
End

'*******************************************************************************

Public Function Procesador() As String 'devuelve el tipo de Procesador
  Dim sPro As String
   Shell "cat /proc/cpuinfo | grep -i ghz | uniq | cut -f2 -d" & ":" To sPro
  Return LTrim(Replace(sPro, "\n", ""))
End

'*******************************************************************************

Public Function Ram() As String 'devuelve cantidad de Ram en MB tambien con free -m
 Dim sRam As String
  Exec ["cat", "/proc/meminfo"] To sRam
  Try sRam = Scan(sRam, "*MemTotal:*\n*")[1] 'Ocultamos el Error si no encuentra MenTotal: * \n
  If Error Then
    sRam = ""
  Else
    While Not IsDigit(Right(sRam))
      sRam = Left(sRam, -1)
    Wend
    sRam = Trim(sRam)
  Endif
  
  If sRam Then
    Try sRam = Format(CInt(sRam) / 1024, "0") & " MB"
    If Not Error Then Return sRam
  Endif
  
  End
  
  '*******************************************************************************

Public Function NombrePC() As String 'devuelve el nombre del pc
  Return System.Host
End

 '*******************************************************************************

Public Function Usuario() As String 'devuelve el usuario activo
  Return System.User.Name
End
'*******************************************************************************

Public Function Usuarios() As String 'devuelve los usuarios que hemos creado
  Dim sUser As String
  Shell "cat /etc/passwd |grep -iw '100.' | cut -d ':' -f1" To sUser
  Return Replace(sUser, "\n", "")
End
'*******************************************************************************

Public Function EEscritorio() As String 'devuelve el entorno del escritorio
  Dim sEscritorio As String
  Shell "env | grep DESKTOP_SESSION= | cut -d '=' -f 2" To sEscritorio
  Return Replace(sEscritorio, "\n", "")
End
 '*******************************************************************************

Public Function GTrabajo() As String 'devuelve el Grupo de trabajo del pc
  Return System.Domain
End

 '*******************************************************************************

Public Function SFicheros(ruta As String) As String 'devuelve el sistema de ficheros  
  Dim sSF As String
  Exec ["df", "-h", ruta] To sSF 'Almacenamos caracteristicas del Sistema de Ficheros pasado en ruta
  Try sSF = Scan(sSF, "*\n*")[1] 'Ocultamos el Error si no encuentra la cadena
  If Error Then sSF = ""
  Return Replace(sSF, "\n", "")
End

 '*******************************************************************************

Public Function VerGambas() As String 'devuelve la versión de gambas intalada en el pc
  Return System.FullVersion
End  

'*******************************************************************************
 Public Function Ls(Ruta As String) As String 'devuelve un listado del directorio pasado en ruta
  Dim sListado As String
  Shell "ls -a " & Ruta To sListado 'Almacenamos listado directorio
  Return RTrim(Replace(sListado, "\n", "|"))
  'Otros comandos que devuelven un listado con las aplicaciones instaladas
  ' dpkg - l
  ' dpkg --get-selections es igual a dpkg -l | cut -d ' ' -f3
  End
 
 '*******************************************************************************

Public Function VerIPs() As String 'devuelve las Ips configuradas en el equipo
  Dim sIPs As String
  Shell "ifconfig | grep inet: |cut -d ':' -f2|cut -d ' ' -f1" To sIPs
  Return RTrim(Replace(sIPs, "\n", " "))
End
 '*******************************************************************************

Public Function UltDigIP() As String 'devuelve el último digito de la Ip
  Dim sIPs As String
  Shell "ifconfig | grep inet: | grep Difus.|cut -d '.' -f5|cut  -d ' ' -f1" To sIPs
  Return RTrim(Replace(sIPs, "\n", " "))
End
 '*******************************************************************************
 

Public Function NSerieHD() As String 'devuelve el número de serie del disco duro para utilizarlo como Pk en la BDD
  Dim sNS As String
  Shell "udevadm info --query=property --name=sda | grep SERIAL_ | awk -F '=' '{print $2}'" To sNS
  Return RTrim(Replace(sNS, "\n", " "))
End

 '*******************************************************************************

Public Function UUIDswap() As String 'devuelve UUID de la swap para utilizarlo como PK de la BDD
  'Requiere permisos de Administrador
  Dim sUID As String
  Shell "blkid | grep swap | cut -d ' ' -f2 |cut -d '=' -f2" To sUID
  Return Left(Right(sUID, -1), -2)
End

Public Function FechaUltAct() As String 'devuelve la Fecha de la ultima vez que se actualizo el sistema
Dim Result, long_iso As String
long_iso = "long-iso"
'Shell "ls -lt --Time-style = " & long_iso & " /var/log/apt | grep -o '\([0-9]\{2,4\}[- ]\)\{3\}[0-9]\{2\}:[0-9]\{2\}' -m 1 " To Result
Shell "ls -lt --time-style=" & long_iso & " /var/log/apt | grep log  -m 1 |cut  -d ' ' -f6" To Result
Return RTrim(Replace(Result, "\n", " "))
End
 

 




===================
No podemos regresar
 
shordi - View user's profileSend private message 
Back to topPage bottom
Reply with quote   Download Post  
Post Re: Extraer Informacion Del Sistema Desde La Terminal 
 
Que bien que esta eso que posteaste. Buen aporte
Saludos.
 



 
tincho - View user's profileSend private message 
Back to topPage bottom
Reply with quote   Download Post  
Post Re: Extraer Informacion Del Sistema Desde La Terminal 
 
http://foro.gambas-es.org/viewtopic.php?f=5&t=4937     whistle
 



 
vuott - View user's profileSend private message 
Back to topPage bottom
Reply with quote   Download Post  
Post Re: Extraer Informacion Del Sistema Desde La Terminal 
 
Shordi:

Citar:
Desarrollado por mi Padawan


¡¡¡ Ohhh !!!Tú buen maestro eres

 yedi

     
 




===================
Blog personal
Web: SoloGambas seleccion de articulos dedicados a Gambas
Visita el Curso de Gambas3 ¡¡¡Gratuito!!!
 
jsbsan - View user's profileSend private messageVisit poster's website 
Back to topPage bottom
Reply with quote   Download Post  
Post Re: Extraer Informacion Del Sistema Desde La Terminal 
 
Verdad tu boca dice...
 




===================
No podemos regresar
 
shordi - View user's profileSend private message 
Back to topPage bottom
Reply with quote   Download Post  
Post Re: Extraer Informacion Del Sistema Desde La Terminal 
 
Disculpen mi ignorancia, es que yo soy mas de startreek, ¿Ell pdawan es el alumno o el maestro?

Saludos.
 



 
tincho - View user's profileSend private message 
Back to topPage bottom
Reply with quote   Download Post  
Post Re: Extraer Informacion Del Sistema Desde La Terminal 
 
Tincho:

Citar:
¿Ell pdawan es el alumno o el maestro?


El alumno... el alumno...   
 




===================
Blog personal
Web: SoloGambas seleccion de articulos dedicados a Gambas
Visita el Curso de Gambas3 ¡¡¡Gratuito!!!
 
jsbsan - View user's profileSend private messageVisit poster's website 
Back to topPage bottom
Reply with quote   Download Post  
Post Re: Extraer Informacion Del Sistema Desde La Terminal 
 
vuott escribió:  
http://foro.gambas-es.org/viewtopic.php?f=5&t=4937     whistle

Buen post también. Seguí la referencia y vi que esta en castellano: sysinfo - devuelve información sobre estadísticas globales del sistema. anche tutte le lingue latine sono un piacere di leggere!
 



 
tincho - View user's profileSend private message 
Back to topPage bottom
Display posts from previous:    
 
HideSimilar Topics
Topic Author Forum Replies Last Post
No new posts Obtener Informacion Desde Internet alan General 1 Monday, 07 March 2011, 02:24 View latest post
shordi
No new posts Extraer Informaciones Desde Un Archivo Aud... vuott Aplicaciones/Fragmentos de Código 0 Saturday, 22 March 2014, 18:45 View latest post
vuott
No new posts Extraer Información Y TAG Desde Un Ficher... vuott Aplicaciones/Fragmentos de Código 1 Thursday, 11 September 2014, 13:00 View latest post
v3ctor
No new posts Navegador Web Desde La Terminal Shell Off-topic 1 Tuesday, 14 April 2020, 17:02 View latest post
tincho
 

Post new topic  Reply to topic  Page 1 of 2
Goto page 1, 2  Next

Users browsing this topic: 0 Registered, 0 Hidden and 1 Guest
Registered Users: None


 
Permissions List
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events



  

 

cron