Foro MetalAficion

CNC => CNC - Software y Controladores => Mensaje iniciado por: abu en 07 Octubre 2017, 13:36

Título: Pequeña utilidad para dar informacion sobre Linuxcnc
Publicado por: abu en 07 Octubre 2017, 13:36
El el directorio /usr/bin se encuentra la utilidad linuxcnc_info
Es un script de shell.
Para correrla desde un terminal de texto, hacer:
cd /usr/bin
./linuxcnc_info

La salida es un fichero de texto, concretamente /tmp/linuxcnc.info
Este fichero contiene información relevante sobre el entorno donde se va a correr linuxcnc.
Para que se visualice la informacion, el sistema debe tener montado uno de los siguientes editores:
gedit
mousepad
geany
nedit
gvim
abiword
La visualización se hace de forma automática utilizando el editor que el sistema encuentre primero de entre los de la lista.

Dejo la version traducida a castellano. Basta con editar como root el archivo linuxcnc_info y superponerle el codigo que se muestra.

Código: [Seleccionar]
#!/bin/bash

# This script creates a file in /tmp and
# opens it with first visual editor found in a search list for editors

# Copyright: 2014
# Author:    Dewey Garrett <dgarrett@panix.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

ofile=/tmp/linuxcnc.info
# all output
exec 1>$ofile
exec 2>&1

# try to find a visual editor to show created file
# use list with existing preference first, then other common editors
editors="$VISUAL gedit mousepad geany nedit gvim abiword"
for e in $editors ; do
  if [  -x "$(which $e)" ] ; then
    VIEWER=$e
    break #use first editor found
  fi
done

function show () {
  if [ -z "$1" ] ; then
    echo
    return
  fi
  name=$1
  shift
  value=$*
  printf "%20s: %s\n" "$name" "$value"
}

function parse_cpuinfo () {
  cat /proc/cpuinfo|grep "$1"|head -1|cut -d: -f2-
}

function parse_after_colon () {
  echo "$*"|cut -d: -f2-
}

function tryversion () {
  prog="$1"
  if [ $(which "$prog") ] ; then
     ans=$($prog --version 2>/dev/null)
     if [ -z "$ans" ] ; then
       echo "?"
     else
       echo "$ans"
     fi
  else
     echo "no_en_PATH"
  fi
}

cat <<EOF
Este fichero puede ser posteado en un sitio web
al objeto de dar informacion sobre el sistema y
la configuracion de linuxcnc.

EOF

echo "Visualizado con "=$VIEWER

show "                       Fecha" $(date)
show "                   Fecha UTC" $(date -u)
show "               este programa" $0
show "hora,tiempo ON,usuario,carga" $(uptime)
show "                Distribucion" $(lsb_release -sa 2>/dev/null)
show "       localizacion linuxcnc" $(which linuxcnc)
show "       directorio de trabajo" $(pwd -P)
show "                     USUARIO" $USER
show "                      LOGING" $LOGNAME
show "             DIRECTORIO HOME" $HOME
show "                      EDITOR" $EDITOR
show "                      VISUAL" $VISUAL
show "                    LENGUAJE" $LANGUAGE
show "                    TERMINAL" $TERM
show "                   COLORTERM" $COLORTERM
show "              NUMERO DISPLAY" $DISPLAY
show "              TAMAÑO DISPLAY" $(parse_after_colon $(xdpyinfo|grep dimensions))
echo
echo "Info proporcionada por comando '-uname-' :"
show "  Nombre nodo host" $(uname -n)
show " Nombre del kernel" $(uname -s)
show "Version del kernel" $(uname -v)
show "           Maquina" $(uname -n)
show "        Procesador" $(uname -p)
show "        Plataforma" $(uname -i)
show " Sistema operativo" $(uname -o)
show ""
echo "Info en /proc:"
show "   Linea cmdline" $(< /proc/cmdline)
show "          Modelo" $(parse_cpuinfo "model name")
show "         Nucleos" $(parse_cpuinfo "cpu cores")
show "             MHz" $(parse_cpuinfo "cpu MHz")
show "Puertos paralelo" $(cat /proc/ioports|grep parport)
show "   Puertos serie" $(cat /proc/ioports|grep serial)
echo
echo "Versiones:"
show "  Compilador gcc" $(gcc --version|head -1)
show "          python" $(python --version 2>&1)
show "             git" $(git --version)
show "             tcl" $(echo "puts $::tcl_version"|tclsh)
show "              tk" $(echo "puts $::tk_version;destroy ."|wish)
show "           glade" $(tryversion glade)
show "      glade-gtk2" $(tryversion glade-gtk2)
echo
echo "Variables linuxcnc (nombre_variable: valor)"
echo
for n in $(linuxcnc_var all) ; do
   show "${n%%=*}" ${n##*=}
done

[ -n $VIEWER ] && $VIEWER "$ofile"

Título: Re:Pequeña utilidad para dar informacion sobre Linuxcnc
Publicado por: Tomy73 en 07 Octubre 2017, 14:11
Muchas gracias Abu.  ;)

Un saludo.
Título: Re:Pequeña utilidad para dar informacion sobre Linuxcnc
Publicado por: Jbecerra en 10 Octubre 2017, 10:21
ABU, ABU, ABU...

(lease como si de una "mani" se tratara )