I have this KSH script, but I can not execute it, does anyone know why?

0

Obviously I gave him the execution permissions with chmod and tried to execute it with "ksh" plus the name of the file and the parameter, but I could not execute it, they are only validations ...

#!/usr/bin/ksh

#Variables generales
P_FECHA=$1
P_PARAMETROS_INGRESADOS=$#

FECHA=$(date "+%Y%m%d")
FECHA_LOG=$(date "+%Y%m%d_%H%M%S")
FECHA_HORA=$(date +"[%F %T]")
PROCESS_ID="RegularizaPortabilidadHist"

#Definicion de directorios
export DIR_RAIZ=/bigdata/dsstage_redes
export BIG_LOG=${DIR_RAIZ}/CargasBAF/log
export BIG_KSH=${DIR_RAIZ}/CargasBAF/ksh
export BIG_COP=${DIR_RAIZ}/radius_unix2dos

# Definicion de archivos
LOG_FILE="${BIG_LOG}/${PROCESS_ID}_${FECHA_LOG}.log"

# Definicion de codigos de error
EXIT_OK=0           # Proceso finaliza OK.
EXIT_VALIDAFILE=151 # Error al validar archivos.
EXIT_VALIDADIR=152  # Error al validar Directorios.
#EXIT_SQL=153        # Error al ejecutar SQL.
EXIT_FTP=153        # Error al ejecutar el FTP.
EXIT_FTP_2=154      # Error en la transferencia FTP.
EXIT_FTP_3=155      # Error en la cantidad de lineas del archivo de control.
EXIT_FTP_4=156      # Error no numerico en el contenido del CTL.
EXIT_FTP_5=157      # Error al comprobar integridad de archivo.
EXIT_RCP_1=158      # Error al ejecutar el comando rcp.
EXIT_RCP_2=159      # Error al copiar archivo desde maquina remota.
EXIT_FECHA=160      # Parametro fecha mal ingresado.
EXIT_PARAMETRO=161  # Cantidad de parametros mal ingresados.
EXIT_JAR=162        # Error en la ejecucion del java.
EXIT_ERR_TMP=163    # Error al eliminar los IDs temporales.
EXIT_ERR_SPN=164    # Error en la traduccion cod_doc1 a cod_spn
EXIT_NODEST=165     # Error con los destinatarios del correo
EXIT_MAILNOK=166    # Error al enviar el correo
EXIT_JAR2=167       # Error en la ejecucion del java.

# Declaracion de funciones
PrintLog(){
    F_FECHA_HORA=$(date +"[%F %T]")
    print -u2 ${F_FECHA_HORA}" $@" 2>&1 | tee -a ${LOG_FILE}
}

validaParametros(){ set -xv
    F_CANT_PARAM_TOTALES=$1
    F_CANT_PARAM_INGRESADOS=$2
    if [[ ${F_CANT_PARAM_INGRESADOS} -ne ${F_CANT_PARAM_TOTALES} ]]
    then
        PrintLog "Cantidad de parametros ingresados incorrecto"
        PrintLog "Proceso Cancela."
        exit ${EXIT_PARAMETRO}
    fi
}

validaExistenciaArchivos(){ set -xv
    F_FILE=$1
    if [[ ! -f ${F_FILE}.0777.BAF_DETALLE_*.dat ]]
    then
        PrintLog "Archivo [${F_FILE}.0777.BAF_DETALLE_*.dat] no existe."
        PrintLog "Proceso se cancela."
        exit ${EXIT_VALIDAFILE}
    fi

    if [[ ! -f ${F_FILE}.0666.BAF_RADIUS.RADIUS_*.dat.txt.gz ]]
    then
      PrintLog "Archivos [${F_FILE}.0666.BAF_RADIUS.RADIUS_*.dat.txt.gz] no existen."
      PrintLog "Proceso se cancela."
      exit ${EXIT_VALIDAFILE}
    fi
}

PrintLog "Validando la cantidad de parametros ingresados"
validaParametros 1 ${P_PARAMETROS_INGRESADOS}

set -xv
cd ${DIR_RAIZ}
validaExistenciaArchivos ${P_FECHA}

PrintLog "Proceso Ejecutado OK."
exit ${EXIT_OK}

Try to execute it like this "ksh TraerArchivosBAF.ksh '20170424'" and in the same directory from where I call the general variables of directories ..

: not found [No such file or directory] : not found [No such file or directory] : not found [No such file or directory] : not found [No such file or directory] : not found [No such file or directory] : not found [No such file or directory] : not found [No such file or directory] : No such file or directory  2017042425 17:33:49] : not found [No such file or directory] : not found [No such file or directory] 'unexpectedsBAF.ksh: line 65: syntax error at line 69:']]

    
asked by Kevin Zambrano 25.04.2017 в 22:39
source

1 answer

1

Run Shell KSH:

sh-4.3$ chmod +x test.ksh                                                                                                                                                       
sh-4.3$ ./test.ksh                                                                                                                                                              
Stack Over Flow Espaniol 

File content test.ksh:

echo "Stack Over Flow Espaniol"

Considerations:

Make sure you have it installed correctly

  

/ bin / ksh

To run a shell .ksh use ./script as long as the script exists in the directory.

Execute Shell KSH On Line

    
answered by 25.04.2017 / 23:03
source