Advertisement
OldManRiver

Untitled

Jul 18th, 2023 (edited)
1,204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.00 KB | None | 0 0
  1. #! /bin/bash
  2.     srcpth='/Books/Spiritual/33-POH-Devotional/Scripts/'
  3.     # Set default vars and output array
  4.     srcfil='/Files/devot-scan.txt'
  5.     tgtdir='/Projects/POH_Dev/'
  6.  
  7.     # Read source file into the first array
  8.     readarray oray < $srcfil
  9.     # Filter out blank lines & lines not containing '3T'
  10.     for i in ${oray[@]}; do
  11.         if [[ "$i" == '/3T/'* ]]; then
  12.             nray+=( "$i" )
  13.         fi
  14.     done
  15.     # Create the DB and Table
  16.     MAKFIL='/data/MySQL/poh-make.sql'
  17.     mysql -u $MUSER -p$MPASS < $MAKFIL
  18.  
  19.     # Read through the array and add to the MySQL DB/Table
  20.     for i in ${nray[@]}; do
  21.         # Make qry to see if record is already in the table
  22.         tstqry='select poh_sdr from POH.poh-src WHERE poh_sdr=$i;'
  23.         ret=$(mysql --user=$MUSER --password=$MPASS
  24.         --database="POH" < "$tstqry" )
  25.         if [ "$ret" -eq 0 ];    then
  26.             echo "Inserting Record!";
  27.             mysql INSERT INTO "poh-src` ( `poh_sdr`, `poh_cdt`, `poh_mdt`
  28.                 VALUES ("$i", NOW(), (NOW());
  29.         fi
  30.     done
  31.     quit;
  32.     exit;
  33. This errors on the INSERT line saying incorrect end of file
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement