Search code examples
linuxshellfilesystemsshredhat

No such file or directory in shell redhat


I am trying to run a .sh shell from my redhat 7.9 machine in a different location than the file is, since this is what is required. But mark error not such file or directory, although I pass the correct path mark error. It is worth mentioning that if it is executed positioned in the path where the shell lives, it executes it without problem, but what is required is to be able to execute it outside of that filesystem. Permissions have already been given to the filesystem, the user was assigned to groups and it still marks the same.

#!/bin/bash

file=$1
#Ruta del proyecto scripts
#ruta=/home/db2inst1
ruta=/opt/IBM/db2/V11.1/bin/

#Conexion a db2
/opt/IBM/db2/V11.1/bin/db2 connect to INFOST > connect_db2_log
fecha="$(date +"%Y-%m-%d - %Hhr_%Mmin_%Sseg")"
date0="$(date +"%Y-%m-%d - %H:%M:%S")"
fecha_flujo_inicio="$(date +%s)"
#echo "Timestamp inicio $fecha_flujo_inicio"

#Lectura del archivo con las tablas a ingestar
while IFS= read line; do

tablaname=$(cut -d " " -f1 <<< $line)
tab_infost=$(cut -d " " -f2 <<< $line)

echo $fecha
echo "Nombre de la tabla: $tablaname"
#sleep 20

/opt/IBM/db2/V11.1/bin/db2 "select count(*) from IS_STAGING.$tablaname" > test_log_count
#echo "des.2019" | "su - db2inst1 -c "db2 'select count(*) from IS_STAGING.$tablaname'" > test_log_count
IFS=$', ' GLOBIGNORE='*' command eval 'L=($(cat test_log_count))'

Count=${L[2]}
echo $Count
#f=$ruta/BITACORA_TABLAS/Bitacora_$tablaname

#Verificacion de que el COUNT de la tabla sea entero 
if [[ "$((Count))" =~ ^[0-9]+$ ]]; then
#Caso en el que la BITACORA esta VACIA
#if [[ ! -s $f ]]; then
    echo "Ingesta de $tablaname & $tab_infost"
        echo "############################################################"
    echo "###################### $tablaname ##########################"
        echo "############################################################"
    echo "Count consultado: $((Count))"
    if [[ ${L[2]} -eq 0 ]]; then
    runtime="1 minute"
    endtime=$(date -ud "$runtime" +%s)
    echo "####### Esperando que se llene la tabla... ######"
    while [[ $(date -u +%s) -le $endtime ]]; do
        #sleep 210
        /opt/IBM/db2/V11.1/bin/db2 "select count(*) from IS_STAGING.$tablaname" > test_log_count
        IFS=$', ' GLOBIGNORE='*' command eval 'L=($(cat test_log_count))'
        if [[ ${L[2]} -eq 0 ]]; then
            continue
        else
            echo "########Se lleno la tabla...##########"
            break
        fi
    done
    fi

    if [[ ${L[2]} -eq 0 ]]; then
        echo "################NO HAY DATOS################"
        time0="$(date +"%Y-%m-%d - %H:%M:%S")"
        echo "###################### ESTA VACIA LA TABLA  ##########################"
        sudo echo $time0 $tablaname $tab_infost ${L[2]} >> $ruta/LOGS_INGESTA/TABLAS_VACIAS
    fi
    #echo ${L[2]}
    #Count diferente de 0
    #sleep 10
    if [[ ${L[2]} -ne 0 ]]; then
        echo "Ingestando..."
        echo "Tabla $tablaname esta llena con ${L[2]}, ejecutando ingesta al INFO STORE..." # Ejecutar ingesta
        #echo "${fecha}" ${L[2]} >> $ruta/BITACORA_TABLAS/Bitacora_$tablaname
            time1="$(date +"%Y-%m-%d-%H:%M:%S")"

        #sudo sh /opt/IBM/i2EIA/toolkit/scripts/setup -t ingestInformationStoreRecords -p importMappingsFile=/opt/IBM/i2EIA/toolkit/configuration/data_actinver/mapping.xml -p importMappingId=$tab_infost -p importMode=STANDARD &
        if [[ ${L[2]} -gt 14000 ]]; then
            sudo sh /opt/IBM/i2EIA/toolkit/scripts/setup -t ingestInformationStoreRecords -p importMappingsFile=/opt/IBM/i2EIA/toolkit/configuration/data_actinver/mapping.xml -p importMappingId=$tab_infost -p importMode=STANDARD &
                sleep 45
            echo "Espera 50 segundos"
        else
            sudo sh /opt/IBM/i2EIA/toolkit/scripts/setup -t ingestInformationStoreRecords -p importMappingsFile=/opt/IBM/i2EIA/toolkit/configuration/data_actinver/mapping.xml -p importMappingId=$tab_infost -p importMode=STANDARD
            
        fi  
        status=$?
            time2="$(date +"%Y-%m-%d-%H:%M:%S")"
        #Estatus de la ejecucion
        #echo "Estatus: $status"
            if [ $status -eq 0 ]; then
                    echo "Estatus de la ejecucion: Exitoso"
                    sudo echo "Tabla: $tab_infost Tiempo: $time1 -> $time2 Numero_registros_ingestados: ${L[2]}" >> $ruta/LOGS_INGESTA/TABLAS_EXITOSAS
            else
                    echo "Estatus de la ejecucion: Failed"
                    #sudo echo "Error_archivo $tab_infost Tiempo: $time0 $time1" Numero_registros: ${L[2]} >> $ruta/log_error_ingesta
                    sudo echo $time1 $tablaname $tab_infost ${L[2]} >> $ruta/LOGS_INGESTA/TABLAS_FALTANTES
            fi
        #break
        #Esperar ingesta
        else
        continue
                #echo "Tabla $tablaname vacia, esperando sea llenada..." # Ejecutar ingesta
            #while
    fi
else
    echo "El Count de la tabla no es un entero"
    sudo echo "Error: $tablename $tab_infost ${L[2]}" >> $ruta/LOGS_INGESTA/TABLAS_ERROR
fi

done < $file

wait
date1="$(date +"%Y-%m-%d - %H:%M:%S")"
fecha_flujo_final="$(date +%s)"
#echo "Timestamp final $fecha_flujo_final"
#t_delta=$((fecha_flujo_final - fecha_flujo_inicio))

sudo echo "Flujo: $file, Fechas: $date0 -> $date1, Tiempo trancurrido: $((fecha_flujo_final - fecha_flujo_inicio)) segundos" >> $ruta/LOGS_INGESTA/FLUJOS_LOG

echo "TERMINO EL FLUJO $file"

the error that marks is the following NO SUCH FILE OR DIRECTORY enter image description here

[i2actinver@v2qlintfinan01 home]$  /opt/IBM/db2/V11.1/bin/script_ingesta_sudo_clean_paralelo.sh FLUJOS/flujo_01
/opt/IBM/db2/V11.1/bin/script_ingesta_sudo_clean_paralelo.sh: line 107: FLUJOS/flujo_01: No such file or directory
TERMINO EL FLUJO FLUJOS/flujo_01
[i2actinver@v2qlintfinan01 home]$

Solution

  • I work by adding the absolute path /opt/IBM/db2/V11.1/bin/script_ingesta_sudo_clean_paralelo.sh /opt/IBM/db2/V11.1/bin/FLUJOS/flujos_01 thank you all.