Variable fetching as null in Shell script

Welcome to Programming Tutorial official website. Today - we are going to cover how to solve / find the solution of this error Variable fetching as null in Shell script on this date .

enter image description here

enter image description here

Hi all Iam facing an issue in the Linux shell script, TFN is fetching as NULL. Can someone help regarding the issue will be helpful

Answer

TFN=`sqlplus -s $LOGNAME1/$PASSWORD1@connstr << EOF > ${LogFileName}
...
EOF`

Is redirecting the sqlplus output to your logfile and the command had no output (it’s gone to the log file) so TFN is empty.

Remove the > ${LogFileName} to TFN gets the value of the query and then echo $FN >> ${LogFileName} if you really want the query results in the log.