1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#!/bin/sh
# echorun 0.01
#
# Copyright (C) 2000: Manel Marin <manel3@apdo.com>
# Licence: GNU GPL version >= 2
#
#
# Lanza comando haciendo echo de la linea de comando si hay mensajes
# (stdout/stderr) o si esta definida la variable de entorno $DEBUG
# (con export DEBUG=si)
#
# PORQUE
# ipchains no da la regla que falla al informar de errores, con lo que
# es complicado solucionarlo cuando tienes muchas...
#
# Uso: echorun comando parametros
#
#
# ------
# Runs command echoing command line if there is message (stdout/stderr)
# or if defined environment var $DEBUG (with export DEBUG=yes)
#
# WHY
# ipchains does not give the rule when reporting errors, so it is
# complicated to fix when you have a lot of them...
#
# Use: echorun command parameters
#
PATH=/sbin:/usr/sbin:/usr/lib/firewall-easy:/bin:/usr/bin
if [ "$DEBUG" != "" ]
then
echo "$*" # Si DEBUG mostrar comando / If DEBUG show command
fi
msg=`$* 2>&1` # Ejecuto comando y leo salida/errores y status
status=$? # Run command and read output/errors and status
# Si hay salida mostrar comando y mensaje / If message show command and message
if [ "$msg" != "" ]
then
echo
echo "---- STATUS:$status --------"
echo " $*"
echo " $msg"
echo
fi
|