removed '/tmp/TMP_SQLITE/temp30'
#
# --- using : test_115-a_list_all_func.sh
# --- using : SCRIPT_NAME : 01-script_install_master_sys_config_script.sh
# --- using : outout : /tmp/TMP_SQLITE/temp30
#
cat /tmp/TMP_SQLITE/temp30
1|01-script_install_master_sys_config_script.sh
.
FINISHED
Now in a larger bash application (30 bash scripts) I added the function used in my test in a script sourced by the main script. I added a call to the function in one of the other script.
I call the function the same way it is written in my test.
I did not get a result, and did not get no error.
CALLING : _TEST_SQLITE_
TMP_SQLITE_DIR : /tmp/TMP_SQLITE
.
rm: cannot remove '/tmp/TMP_SQLITE/temp30': No such file or directory
#
# --- _TEST_SQLITE_
# --- using : DATABASE_LOGGER : /run/media/user_install/NVIDIA_OPTIMUS/30_SQLITE/DATALOGGER/NVIDIA_OPTIMUS_DATALOGGER.db
# --- using : SCRIPT_NAME_2 : 01-script_install_system_config_script.sh
# --- using : output : /tmp/TMP_SQLITE/temp30
#
cat /tmp/TMP_SQLITE/temp30
RET_CODE : 0
The directory "$TMP_SQLITE_DIR/temp30" is either not created or it is already deleted. before the function was executed. At any rate add a test before running a destructive command such as rm. In a scenario that the variable is empty then rm would run:
rm -v /temp30
Instead of
rm -v “$TMP_SQLITE_DIR/temp30”
Which Is what exactly happen to a script that was written by some developer (nvidia installer iirc) but the variable was empty in some cases. Long story short it deleted the / directory or some parts of it. Debugging and logging the output somewhere should be a start.
sqlite3 "$DATABASE_LOGGER" << EOF
.output "$TMP_SQLITE_DIR/temp30"
select id,SCRIPT_NAME from datalogger where SCRIPT_NAME = '$A_SCRIPT' ;
EOF
I did not get any data in the file pointed by
.output
I did not get any error.
For the moment I have bypassed the problem using the following syntax: sqlite3 "$DATABASE_LOGGER" 'select id,SCRIPT_NAME from datalogger where SCRIPT_NAME = '''"'$A_SCRIPT'"''' ;' > "$TMP_SQLITE_DIR/temp30"
But I would like to know why the first syntax does not work.