Bash script sql statement won't execute successfully

My code is sending all output to the c.txt file, which indicates the script isn't working correctly. The script does successfully connect to the database however, so I'm not sure exactly what I'm doing wrong. Any help is greatly appreciated.

#!/bin/bash

INPUT_FILE='test.csv'
OUTPUT_FILE='roles.txt'

IFS=','

while read f1 f2 f3 f4 f5 f6 f7; do

   user_id=$(echo "${f1//\"/}")
   first_name=$(echo "${f2//\"/}")
   last_name=$(echo "${f3//\"/}")
   title=$(echo "${f4//\"/}")
   requestor=$(echo "${f5//\"/}")
   request_email=$(echo "${f6//\"/}")
   declare -a roles=$(echo "$f7"| sed 's/"\(.[^"]*\)".*/\1/')
   declare -a tasks=$(echo "$f7"| sed 's/".[^"]*".*"\(.[^"]*\)"/\1/')

   roles=${roles//, /,}
   tasks=${tasks//, /,}

   arr=$(echo "$roles" | tr "," "\n")

   while read line; do
         sql="select id from roles where role_name='$line'"
         #echo $sql         
         if sql_string=$(sshpass -p XXXXXXXX ssh me@11.11.11.11 'mysql --skip-column-names -u me -pXXXXXXXXXX database -e '$sql';'); then
            if [[ ! -z $sql_string ]]; then
               echo "$sql_string" >> a.txt
            else
               echo "No Data Found" >> b.txt
            fi
         else
            echo "$sql_string" >> c.txt
         fi
   done <<< "$arr"


done < $INPUT_FILE

Open in new window

TampaJayAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Walter RitzelSenior Software EngineerCommented:
Can you attach the c.txt file, so we can see the error message?
0
tel2Commented:
If we could see the input (test.csv) as well, that could be useful.
0
TampaJayAuthor Commented:
I won't print out the entire output of c.txt, but this is what spits out:

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Usage: mysql [OPTIONS] [database]
  -?, --help          Display this help and exit.
  -I, --help          Synonym for -?
  --auto-rehash       Enable automatic rehashing. One doesn't need to use
                      'rehash' to get table and field completion, but startup
                      and reconnecting may take a longer time. Disable with
                      --disable-auto-rehash.
                      (Defaults to on; use --skip-auto-rehash to disable.)
  -A, --no-auto-rehash
                      No automatic rehashing. One has to use 'rehash' to get
                      table and field completion. This gives a quicker start of
                      mysql and disables rehashing on reconnect.
  --auto-vertical-output
                      Automatically switch to vertical output mode if the
                      result is wider than the terminal width.

Open in new window


----------------------------------

I don't think it would be much help to add test.csv, but I can print out the output of the $sql variable which is getting entered into the $sql_string variable. These are the results when I just remove the if statement and output an 'echo $mysql' statement.

select id from roles where role_name='Role A'
select id from roles where role_name='Role B'
select id from roles where role_name='Role C'
select id from roles where role_name='Role D'
select id from roles where role_name='Role E'
select id from roles where role_name='Role F'
select id from roles where role_name='Role G'
select id from roles where role_name='Role H'
select id from roles where role_name='Role I'

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

TampaJayAuthor Commented:
I figured out the issue initially, but now I have a different issue:

So,

I almost got my script working, but there's one issue:

User A has these roles - Role A, Role B, Role C
User B - Role D, Role E, Role F
User C - Role G, Role H, Role I

My script has an issue where it is only printing out the first role of each user instead of all the roles:

So it is coming out as the following:

Role A
Role D
Role G

When running the following, the script works fine:

while read line; do
       echo $line
done <<< "$arr"

But the following is broken:

#   while read line; do
#     echo $sql        
#     if sql_string=$(sshpass -p xxxxxx ssh jlefler@511.11.11.11 'mysql --skip-column-names -u root -pxxxxxxx database -e "select id from roles where binary role_name='"'${line}';"'"'); then
#         if [[ ! -z $sql_string ]]; then
#            echo $line - "$sql_string" >> a.txt
#         else
#            echo "No Data Found" >> b.txt
#      fi
#      else
#         echo "$sql_string" >> c.txt
#      fi
#   done <<< "$arr"

So when I run the commented portion, I get the following:

Role A - 1
Role D - 4
Role G - 7

As you can see here, it's only looking at first role of each person. It should look like the following:

Role A - 1
Role B - 6
Role C - 8
Role D - 4
Role E - 11
Role F - 8
Role G - 7
Role H - 9
Role I - 10
0
TampaJayAuthor Commented:
When I try to mix it up as follows:

for i in "${arr[@]}"
do
   echo $i
   if sql_string=$(sshpass -p xxxxxx ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='"'${i}';"'"'); then
      if [[ -n $sql_string ]]; then
         echo  $i - "$sql_string" >> a.txt
      else
         echo "No Data Found" >> b.txt
      fi
      else
         echo "$sql_string" >> c.txt
      fi
done

Open in new window


Now the output is getting directed to b.txt.
0
TampaJayAuthor Commented:
Let me make this more simple:

I have a variable that contains data like this:

    Case Manager
    Case Collector
    Engineer

These are all fields in my database that have an associated ID.

The script I am using below will only read the first entry:

    while read line; do
          if sql_string=$(sshpass -p xxxxxxx ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxx database -e "select id from roles where binary role_name='"'${line}';"'"'); then
             if [[ -n $sql_string ]]; then
                echo  $line - "$sql_string" >> a.txt
             else
                echo "No Data Found" >> b.txt
          fi
          else
             echo "Query Didn't Execute"
          fi
    done <<< "$arr"

Open in new window


So the output only looks like this:

    Case Manger - 1

INSTEAD of the desired output:

    Case Manager - 1
    Case Collector - 5
    Engineer - 11
0
TampaJayAuthor Commented:
OK, I've solved most of the problems with some modifications of a loop.

My last problem is that the script is only reading one line of the test.csv file. It needs to read all lines.

Current code:

#!/bin/bash
> a.txt
> b.txt

INPUT_FILE='test.csv'
#OUTPUT_FILE='roles.txt'

IFS=','

while read f1 f2 f3 f4 f5 f6 f7; do

   user_id=$(echo "${f1//\"/}")
   first_name=$(echo "${f2//\"/}")
   last_name=$(echo "${f3//\"/}")
   title=$(echo "${f4//\"/}")
   requestor=$(echo "${f5//\"/}")
   request_email=$(echo "${f6//\"/}")
   roles=$(echo "$f7"| sed 's/"\(.[^"]*\)".*/\1/')
   tasks=$(echo "$f7"| sed 's/".[^"]*".*"\(.[^"]*\)"/\1/')

   roles=${roles//, /,}
   tasks=${tasks//, /,}

   for i in $roles
   do
       if sql_string=$(sshpass -p XXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxxx database -e "select id from roles where binary role_name='"'${i}';"'"'); then
          if [[ -n $sql_string ]]; then
            echo  "$i" - "$sql_string" >> a.txt
          else
            echo "No Data Found" >> b.txt
       fi
       else
          echo "Query Didn't Execute"
       fi
   done

   for i in $tasks
   do
       if sql_string=$(sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxxx database -e "select id from groups where binary group_name='"'${i}';"'"'); then
          if [[ -n $sql_string ]]; then
            echo  "$i" - "$sql_string" >> a.txt
          else
            echo "No Data Found" >> b.txt
       fi
       else
          echo "Query Didn't Execute"
       fi
   done

done < $INPUT_FILE

Open in new window

0
TampaJayAuthor Commented:
No assistance here?
0
tel2Commented:
Hi TampaJay,

I'd love to help you, but you seem to have decided that what I asked for won't be useful to me.  If you want my help, please don't stop me from helping you by making such decisions for me.  In other words, if you want our (free) help then I suggest you make it easy for us by not tying our hands behind our backs.  How am I supposed to test your script without input data?  Input data is almost always useful for troubleshooting programming issues like these, so I suggest you get into the habit of supplying it with your original question in future.  If you make it easier for us, then you are more likely to get a faster solution.

If you want my help, could you please now:

1. Attach text.csv here, (or at least the first 2 lines of it).

2. After this line:
    while read f1 f2 f3 f4 f5 f6 f7; do
please insert this:
    echo "f1='$f1', f2='$f2', f3='$f3', f4='$f4', f5='$f5', f6='$f6', f7='$f7'"
then rerun it and paste your output here.

Thanks.
0
TampaJayAuthor Commented:
Contents of the test.csv file:

jlefler,Jay,Lefler,"Tape Monkey","Boss Man",bossman@job.com,"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"
bmccool,Ben,McCool,"Production Control Analyst","Boss Man",ssharp@job.com,"Admin, Care Coordinator Supervisor, Reports","Hitting It, Catching It, Catcher"
bman,Big,Man,"Soldier","Boss Man",bossman@job.com,"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"

Open in new window


Output of your suggested echo line:

f1='jlefler', f2='Jay', f3='Lefler', f4='"Tape Monkey"', f5='"Boss Man"', f6='bossman@job.com', f7='"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'

Open in new window

0
tel2Commented:
Thanks TampaJay.  That was useful - I was able to test (some of) the script, though some of it fails because I don't have access to things.

Q1. Did you get ANY other output or errors?  If so, please attach it all here.

Q2. Lines like this:
        if sql_string=$(sshpass -p XXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxxx database -e "select id from roles where binary role_name='"'${i}';"'"'); then
do not look like valid bash syntax (though the parser seems to be allowing it).

Q3. Please run the script again in debug mode like this:
        bash -x yourscriptname
and attached all the output here.

Q4. Before I do any more on this, why do you need this script, please?  Is it home work, or what?

Please answer questions Q1-Q4 above, and I might then be able to help you more.
0
TampaJayAuthor Commented:
Q1 - this is all the output below

Q2 - this is valid bash syntax

Q3 - Output below

Q4 - this is something I'm trying to write for work - not an assigned project, just something I'm trying to work on my own

Full contents of the 'bash -x...' script execution:

+ INPUT_FILE=test.csv
+ IFS=,
+ read f1 f2 f3 f4 f5 f6 f7
++ echo jlefler
+ user_id=jlefler
++ echo Jay
+ first_name=Jay
++ echo Lefler
+ last_name=Lefler
++ echo 'Tape Monkey'
+ title='Tape Monkey'
++ echo 'Boss Man'
+ requestor='Boss Man'
++ echo bossman@job.com
+ request_email=bossman@job.com
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/"\(.[^"]*\)".*/\1/'
+ roles='Constructor, Deconstructor, Transformer'
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/".[^"]*".*"\(.[^"]*\)"/\1/'
+ tasks='Explosives, Gassy Extracts, Grenade Throwing'
+ roles=Constructor,Deconstructor,Transformer
+ tasks='Explosives,Gassy Extracts,Grenade Throwing'
+ for i in '$roles'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='\''Constructor'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Constructor is a bad role'
+ for i in '$roles'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='\''Deconstructor'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Deconstructor is a bad role'
+ for i in '$roles'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='\''Transformer'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Transformer is a bad role'
+ for i in '$tasks'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from groups where binary group_name='\''Explosives'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Explosives is a bad task'
+ for i in '$tasks'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from groups where binary group_name='\''Gassy Extracts'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Gassy Extracts is a bad task'
+ for i in '$tasks'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from groups where binary group_name='\''Grenade Throwing'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Grenade Throwing is a bad task'
+ unset IFS
+ read f1 f2 f3 f4 f5 f6 f7

Open in new window

0
tel2Commented:
Thanks TampaJay,

Good answers.  You're right about Q2 - my mistake, sorry.  I've just never seen that done in bash before.

Q5. I see the 2nd to bottom line of your output is "unset IFS".  Do you know where that's coming from?  I don't see that command in the last version of the code you supplied, and I don't get that when I run it.

Q6. Is the code you are running exactly the same as the code you last posted above?

When I run your script in debug mode, my output ends with:
    + read f1 f2 f3 f4 f5 f6 f7
which makes sense, coz that is when it would read the end-of-file and then drop out of the main loop.  And that is after it's processed all 3 input lines, but I see yours is only processing 1 line, as you have said.

Please update your code as follows.  Insert:
    echo "End of loop"
before the last "done < $INPUT_FILE", and
    echo "End of script"
after the "done < $INPUT_FILE".

Q7. Please post your updated code.

Q8. Please post ALL the debug output that you get when you run the updated code.

Q9. What debug output do you get when you run this cut-down version of the script?:
#!/bin/bash
INPUT_FILE='test.csv'
IFS=','
while read f1 f2 f3 f4 f5 f6 f7; do
        echo "f1='$f1', f2='$f2', f3='$f3', f4='$f4', f5='$f5', f6='$f6', f7='$f7'"
done < $INPUT_FILE
echo "Finished"

Open in new window

0
TampaJayAuthor Commented:
Q5 - I just forgot to remove that from when I was doing some troubleshooting.

Q6 - With the exception of masking the private information, the script is exactly the same

Q7 -

#!/bin/bash
> sql_stmnts.txt
> bad_info.txt

INPUT_FILE='test.csv'

IFS=','

while read f1 f2 f3 f4 f5 f6 f7; do

   #echo "f1='$f1', f2='$f2', f3='$f3', f4='$f4', f5='$f5', f6='$f6', f7='$f7'"

   user_id=$(echo "${f1//\"/}")
   first_name=$(echo "${f2//\"/}")
   last_name=$(echo "${f3//\"/}")
   title=$(echo "${f4//\"/}")
   requestor=$(echo "${f5//\"/}")
   request_email=$(echo "${f6//\"/}")
   roles=$(echo "$f7"| sed 's/"\(.[^"]*\)".*/\1/')
   tasks=$(echo "$f7"| sed 's/".[^"]*".*"\(.[^"]*\)"/\1/')

   roles=${roles//, /,}
   tasks=${tasks//, /,}

   for i in $roles
   do
       if sql_string=$(sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='"'${i}';"'"'); then
          if [[ -n $sql_string ]]; then
             echo  "insert into user_roles (USER_ID, ROLE_ID, version) select id, $sql_string, 1 from users where user_id in ('$user_id');" >> sql_stmnts.txt
          else
             echo "$user_id - $i is a bad role" >> bad_info.txt
       fi
       else
          echo "Query Didn't Execute"
       fi
   done

   for i in $tasks
   do
       if sql_string=$(sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from groups where binary group_name='"'${i}';"'"'); then
          if [[ -n $sql_string ]]; then
             echo  "insert into membership (USER_ID, group_ID, version) select id, $sql_string, 1 from users where user_id in ('$user_id');" >> sql_stmnts.txt
          else
             echo "$user_id - $i is a bad task" >> bad_info.txt
       fi
       else
          echo "Query Didn't Execute"
       fi
   done

echo "End of loop"
done < $INPUT_FILE
echo "End of script"

Open in new window


Q8 -

+ INPUT_FILE=test.csv
+ IFS=,
+ read f1 f2 f3 f4 f5 f6 f7
++ echo jlefler
+ user_id=jlefler
++ echo Jay
+ first_name=Jay
++ echo Lefler
+ last_name=Lefler
++ echo 'Tape Monkey'
+ title='Tape Monkey'
++ echo 'Boss Man'
+ requestor='Boss Man'
++ echo bossman@job.com
+ request_email=bossman@job.com
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/"\(.[^"]*\)".*/\1/'
+ roles='Constructor, Deconstructor, Transformer'
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/".[^"]*".*"\(.[^"]*\)"/\1/'
+ tasks='Explosives, Gassy Extracts, Grenade Throwing'
+ roles=Constructor,Deconstructor,Transformer
+ tasks='Explosives,Gassy Extracts,Grenade Throwing'
+ for i in '$roles'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxxx database -e "select id from roles where binary role_name='\''Constructor'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Constructor is a bad role'
+ for i in '$roles'
++ sshpass -p XXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='\''Deconstructor'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Deconstructor is a bad role'
+ for i in '$roles'
++ sshpass -p XXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='\''Transformer'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Transformer is a bad role'
+ for i in '$tasks'
++ sshpass -p XXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from groups where binary group_name='\''Explosives'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Explosives is a bad task'
+ for i in '$tasks'
++ sshpass -p XXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from groups where binary group_name='\''Gassy Extracts'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Gassy Extracts is a bad task'
+ for i in '$tasks'
++ sshpass -p XXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from groups where binary group_name='\''Grenade Throwing'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Grenade Throwing is a bad task'
+ echo 'End of loop'
End of loop
+ read f1 f2 f3 f4 f5 f6 f7
+ echo 'End of script'
End of script

Open in new window

0
tel2Commented:
OK, and your response to Q9?
0
TampaJayAuthor Commented:
Q9

f1='jlefler', f2='Jay', f3='Lefler', f4='"Tape Monkey"', f5='"Boss Man"', f6='bossman@job.com', f7='"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
f1='bmccool', f2='Ben', f3='McCool', f4='"Production Control Analyst"', f5='"Boss Man"', f6='ssharp@job.com', f7='"Admin, Care Coordinator Supervisor, Reports","Hitting It, Catching It, Catcher"'
f1='bman', f2='Big', f3='Man', f4='"Soldier"', f5='"Boss Man"', f6='bossman@job.com', f7='"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
Finished

Open in new window

0
tel2Commented:
OK - now run this, exactly as it is, in debug mode, and give me all the output please.

#!/bin/bash
> sql_stmnts.txt
> bad_info.txt

INPUT_FILE='test.csv'

IFS=','

while read f1 f2 f3 f4 f5 f6 f7; do

   echo "f1='$f1', f2='$f2', f3='$f3', f4='$f4', f5='$f5', f6='$f6', f7='$f7'"

   user_id=$(echo "${f1//\"/}")
   first_name=$(echo "${f2//\"/}")
   last_name=$(echo "${f3//\"/}")
   title=$(echo "${f4//\"/}")
   requestor=$(echo "${f5//\"/}")
   request_email=$(echo "${f6//\"/}")
   roles=$(echo "$f7"| sed 's/"\(.[^"]*\)".*/\1/')
   tasks=$(echo "$f7"| sed 's/".[^"]*".*"\(.[^"]*\)"/\1/')

   roles=${roles//, /,}
   tasks=${tasks//, /,}

#  for i in $roles
#  do
#      if sql_string=$(sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='"'${i}';"'"'); then
#         if [[ -n $sql_string ]]; then
#            echo  "insert into user_roles (USER_ID, ROLE_ID, version) select id, $sql_string, 1 from users where user_id in ('$user_id');" >> sql_stmnts.txt
#         else
#            echo "$user_id - $i is a bad role" >> bad_info.txt
#      fi
#      else
#         echo "Query Didn't Execute"
#      fi
#  done

#  for i in $tasks
#  do
#      if sql_string=$(sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from groups where binary group_name='"'${i}';"'"'); then
#         if [[ -n $sql_string ]]; then
#            echo  "insert into membership (USER_ID, group_ID, version) select id, $sql_string, 1 from users where user_id in ('$user_id');" >> sql_stmnts.txt
#         else
#            echo "$user_id - $i is a bad task" >> bad_info.txt
#      fi
#      else
#         echo "Query Didn't Execute"
#      fi
#  done

echo "End of loop"
done < $INPUT_FILE
echo "End of script"

Open in new window

0
TampaJayAuthor Commented:
Here is the requested output:

+ INPUT_FILE=test.csv
+ IFS=,
+ read f1 f2 f3 f4 f5 f6 f7
+ echo 'f1='\''jlefler'\'', f2='\''Jay'\'', f3='\''Lefler'\'', f4='\''"Tape Monkey"'\'', f5='\''"Boss Man"'\'', f6='\''bossman@job.com'\'', f7='\''"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'\'''
f1='jlefler', f2='Jay', f3='Lefler', f4='"Tape Monkey"', f5='"Boss Man"', f6='bossman@job.com', f7='"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ echo jlefler
+ user_id=jlefler
++ echo Jay
+ first_name=Jay
++ echo Lefler
+ last_name=Lefler
++ echo 'Tape Monkey'
+ title='Tape Monkey'
++ echo 'Boss Man'
+ requestor='Boss Man'
++ echo bossman@job.com
+ request_email=bossman@job.com
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/"\(.[^"]*\)".*/\1/'
+ roles='Constructor, Deconstructor, Transformer'
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/".[^"]*".*"\(.[^"]*\)"/\1/'
+ tasks='Explosives, Gassy Extracts, Grenade Throwing'
+ roles=Constructor,Deconstructor,Transformer
+ tasks='Explosives,Gassy Extracts,Grenade Throwing'
+ echo 'End of loop'
End of loop
+ read f1 f2 f3 f4 f5 f6 f7
+ echo 'f1='\''bmccool'\'', f2='\''Ben'\'', f3='\''McCool'\'', f4='\''"Production Control Analyst"'\'', f5='\''"Boss Man"'\'', f6='\''ssharp@job.com'\'', f7='\''"Admin, Care Coordinator Supervisor, Reports","Hitting It, Catching It, Catcher"'\'''
f1='bmccool', f2='Ben', f3='McCool', f4='"Production Control Analyst"', f5='"Boss Man"', f6='ssharp@job.com', f7='"Admin, Care Coordinator Supervisor, Reports","Hitting It, Catching It, Catcher"'
++ echo bmccool
+ user_id=bmccool
++ echo Ben
+ first_name=Ben
++ echo McCool
+ last_name=McCool
++ echo 'Production Control Analyst'
+ title='Production Control Analyst'
++ echo 'Boss Man'
+ requestor='Boss Man'
++ echo ssharp@job.com
+ request_email=ssharp@job.com
++ echo '"Admin, Care Coordinator Supervisor, Reports","Hitting It, Catching It, Catcher"'
++ sed 's/"\(.[^"]*\)".*/\1/'
+ roles='Admin, Care Coordinator Supervisor, Reports'
++ echo '"Admin, Care Coordinator Supervisor, Reports","Hitting It, Catching It, Catcher"'
++ sed 's/".[^"]*".*"\(.[^"]*\)"/\1/'
+ tasks='Hitting It, Catching It, Catcher'
+ roles='Admin,Care Coordinator Supervisor,Reports'
+ tasks='Hitting It,Catching It,Catcher'
+ echo 'End of loop'
End of loop
+ read f1 f2 f3 f4 f5 f6 f7
+ echo 'f1='\''bman'\'', f2='\''Big'\'', f3='\''Man'\'', f4='\''"Soldier"'\'', f5='\''"Boss Man"'\'', f6='\''bossman@job.com'\'', f7='\''"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'\'''
f1='bman', f2='Big', f3='Man', f4='"Soldier"', f5='"Boss Man"', f6='bossman@job.com', f7='"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ echo bman
+ user_id=bman
++ echo Big
+ first_name=Big
++ echo Man
+ last_name=Man
++ echo Soldier
+ title=Soldier
++ echo 'Boss Man'
+ requestor='Boss Man'
++ echo bossman@job.com
+ request_email=bossman@job.com
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/"\(.[^"]*\)".*/\1/'
+ roles='Constructor, Deconstructor, Transformer'
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/".[^"]*".*"\(.[^"]*\)"/\1/'
+ tasks='Explosives, Gassy Extracts, Grenade Throwing'
+ roles=Constructor,Deconstructor,Transformer
+ tasks='Explosives,Gassy Extracts,Grenade Throwing'
+ echo 'End of loop'
End of loop
+ read f1 f2 f3 f4 f5 f6 f7
+ echo 'End of script'
End of script

Open in new window

0
tel2Commented:
Good.  That was your code with the roles and tasks loops commented out, and you can see from the output that it processed all 3 rows (try running it in non-debug mode too if you like).

The following has just the tasks loop commented out.  Please run it as is and show me the debug output.

#!/bin/bash
> sql_stmnts.txt
> bad_info.txt

INPUT_FILE='test.csv'

IFS=','

while read f1 f2 f3 f4 f5 f6 f7; do

   echo "f1='$f1', f2='$f2', f3='$f3', f4='$f4', f5='$f5', f6='$f6', f7='$f7'"

   user_id=$(echo "${f1//\"/}")
   first_name=$(echo "${f2//\"/}")
   last_name=$(echo "${f3//\"/}")
   title=$(echo "${f4//\"/}")
   requestor=$(echo "${f5//\"/}")
   request_email=$(echo "${f6//\"/}")
   roles=$(echo "$f7"| sed 's/"\(.[^"]*\)".*/\1/')
   tasks=$(echo "$f7"| sed 's/".[^"]*".*"\(.[^"]*\)"/\1/')

   roles=${roles//, /,}
   tasks=${tasks//, /,}

   for i in $roles
   do
       if sql_string=$(sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='"'${i}';"'"'); then
          if [[ -n $sql_string ]]; then
             echo  "insert into user_roles (USER_ID, ROLE_ID, version) select id, $sql_string, 1 from users where user_id in ('$user_id');" >> sql_stmnts.txt
          else
             echo "$user_id - $i is a bad role" >> bad_info.txt
       fi
       else
          echo "Query Didn't Execute"
       fi
   done

#  for i in $tasks
#  do
#      if sql_string=$(sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from groups where binary group_name='"'${i}';"'"'); then
#         if [[ -n $sql_string ]]; then
#            echo  "insert into membership (USER_ID, group_ID, version) select id, $sql_string, 1 from users where user_id in ('$user_id');" >> sql_stmnts.txt
#         else
#            echo "$user_id - $i is a bad task" >> bad_info.txt
#      fi
#      else
#         echo "Query Didn't Execute"
#      fi
#  done

echo "End of loop"
done < $INPUT_FILE
echo "End of script"

Open in new window

0
tel2Commented:
...and if that processes all 3 lines, uncomment the roles loop.
And if that processes all 3 lines, then there's something different about your code that the code we have here.

The general principle being, if something complex doesn't work and you don't know how to debug it, reduce it to something simpler until it works, then re-introduce the complexities, bit by bit (or byte by byte, or line by line, or section by section), until you can see exactly what it is that's making it fail.  Armed with that principle, you can probably do the rest yourself, but let me know if you get stuck.
0
TampaJayAuthor Commented:
Results from just uncommenting roles portion:

+ INPUT_FILE=test.csv
+ IFS=,
+ read f1 f2 f3 f4 f5 f6 f7
+ echo 'f1='\''jlefler'\'', f2='\''Jay'\'', f3='\''Lefler'\'', f4='\''"Tape Monkey"'\'', f5='\''"Boss Man"'\'', f6='\''bossman@job.com'\'', f7='\''"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'\'''
f1='jlefler', f2='Jay', f3='Lefler', f4='"Tape Monkey"', f5='"Boss Man"', f6='bossman@job.com', f7='"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ echo jlefler
+ user_id=jlefler
++ echo Jay
+ first_name=Jay
++ echo Lefler
+ last_name=Lefler
++ echo 'Tape Monkey'
+ title='Tape Monkey'
++ echo 'Boss Man'
+ requestor='Boss Man'
++ echo bossman@job.com
+ request_email=bossman@job.com
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/"\(.[^"]*\)".*/\1/'
+ roles='Constructor, Deconstructor, Transformer'
++ echo '"Constructor, Deconstructor, Transformer","Explosives, Gassy Extracts, Grenade Throwing"'
++ sed 's/".[^"]*".*"\(.[^"]*\)"/\1/'
+ tasks='Explosives, Gassy Extracts, Grenade Throwing'
+ roles=Constructor,Deconstructor,Transformer
+ tasks='Explosives,Gassy Extracts,Grenade Throwing'
+ for i in '$roles'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='\''Constructor'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Constructor is a bad role'
+ for i in '$roles'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='\''Deconstructor'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Deconstructor is a bad role'
+ for i in '$roles'
++ sshpass -p XXXXXXXX ssh jlefler@11.11.11.11'mysql --skip-column-names -u root -pxxxxxxxx database -e "select id from roles where binary role_name='\''Transformer'\'';"'
********************************************************************
*                                                                  *
* This system is for the use of authorized users only.  Usage of   *
* this system may be monitored and recorded by system personnel.   *
*                                                                  *
* Anyone using this system expressly consents to such monitoring   *
* and is advised that if such monitoring reveals possible          *
* evidence of criminal activity, system personnel may provide the  *
* evidence from such monitoring to law enforcement officials.      *
*                                                                  *
********************************************************************
Warning: Using a password on the command line interface can be insecure.
+ sql_string=
+ [[ -n '' ]]
+ echo 'jlefler - Transformer is a bad role'
+ echo 'End of loop'
End of loop
+ read f1 f2 f3 f4 f5 f6 f7
+ echo 'End of script'
End of script

Open in new window

0
tel2Commented:
OK.

Comment out the roles processing and uncomment the tasks section, and post the debug output here.
0
TampaJayAuthor Commented:
I rewrote the entire script and got it working. It came to a point that I just had to guess at a few of the variables (whether to " or not, etc., etc).

I've attached the code just in case you're interested:

#!/bin/bash

#Role IDs and Role Names will be stored in this document.
> role_info.txt
#Task IDs and Task Names will be stored in this document.
> task_info.txt
> role_adds.sql
> task_adds.sql
> user_adds.sql
> demo_adds.sql
> bad_roles.txt
> bad_tasks.txt

#Gather all the role ids and role names.
if sql_string=$(sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -h databasedb -u database -pxxxxxxxx database -e "select id, role_name from roles";'); then
   if [[ -n $sql_string ]]; then
      #If the role name is valid, prepare insert statement for user.
      echo "$sql_string" >> role_info.txt
   else
      #If role name doesn't exist, print out the user id and the bad role name.
      echo "There are no roles in the database." >> bad_info.txt
   fi
else
   #If database connection failes, print out error message.
   echo "Query Didn't Execute"
fi

#Gather all the task ids and task names.
if sql_string=$(sshpass -p XXXXXXXX ssh jlefler@11.11.11.11 'mysql --skip-column-names -h databasedb -u database -pxxxxxxxx database -e "select id, group_name from groups";'); then
   if [[ -n $sql_string ]]; then
      #If the task name is valid, prepare insert statement for user.
      echo "$sql_string" >> task_info.txt
   else
      #If task name doesn't exist, print out the user id and the bad task name.
      echo "There are no tasks in the database." >> bad_info.txt
   fi
else
   #If database connection failes, print out error message.
   echo "Query Didn't Execute"
fi

#Convert comma delimited file (test.csv) to pipe delimited file.
./repl_comma_pipes.sh

#Our pipe delimited file.
INPUT_FILE='new_test.csv'

#Cycle through our document - each line has 14 fields.
lines=$(wc -l < $INPUT_FILE)
((lines--))
counter=1


#For each line of file, capture the variables and remove leading and traililng spaces.
while [ $counter -le $lines ]; do
   user_id=$(awk -F"|" '(NR == '$counter+1'){print $1}' $INPUT_FILE)
   user_id=`eval echo $user_id`
   first_name=$(awk -F "|" '(NR == '$counter+1'){print $2}' $INPUT_FILE)
   first_name=`eval echo $first_name`
   last_name=$(awk -F "|" '(NR == '$counter+1'){print $3}' $INPUT_FILE)
   last_name=`eval echo $last_name`
   password=$(awk -F"|" '(NR == '$counter+1'){print $4}' $INPUT_FILE)
   password=`eval echo $password`
   email=$(awk -F "|" '(NR == '$counter+1'){print $5}' $INPUT_FILE)
   email=`eval echo $email`
   create_date=$(awk -F "|" '(NR == '$counter+1'){print $6}' $INPUT_FILE)
   create_date=`eval echo $create_date`
   request_date=$(awk -F "|" '(NR == '$counter+1'){print $7}' $INPUT_FILE)
   request_date=`eval echo $request_date`
   requestor=$(awk -F "|" '(NR == '$counter+1'){print $8}' $INPUT_FILE)
   requestor=`eval echo $requestor`
   title=$(awk -F "|" '(NR == '$counter+1'){print $9}' $INPUT_FILE)
   title=`eval echo $title`
   site_location=$(awk -F "|" '(NR == '$counter+1'){print $10}' $INPUT_FILE)
   site_location=`eval echo $site_location`
   client=$(awk -F "|" '(NR == '$counter+1'){print $11}' $INPUT_FILE)
   client=`eval echo $client`
   request_email=$(awk -F "|" '(NR == '$counter+1'){print $12}' $INPUT_FILE)
   request_email=`eval echo $request_email`
   roles=$(awk -F "|" '(NR == '$counter+1'){print $13}' $INPUT_FILE)
   roles=`eval echo $roles`
   tasks=$(awk -F "|" '(NR == '$counter+1'){print $14}' $INPUT_FILE)
   tasks=`eval echo $tasks`

   #Replace any spaces in the roles and tasks variables, so they are easier to manipulate as an array.
   roles=${roles//, /,}
   tasks=${tasks//, /,}

   echo "INSERT INTO users(user_id, first, last, password, email, createdate, requestdate, request by)VALUES('$user_id','$first_name','$last_name',md5('$password'),'$email','$create_date','$request_date','$requestor');" >> user_adds.sql

   echo "INSERT INTO user_demographics(user_id, title, site_location, comment, client_name, requester_email)VALUES('$user_id','$title','$site_location','$title','$client','$request_email');" >> demo_adds.sql

   #Assign a delimeter since we will be cycling through two comma delimited arrays.
   IFS=','

   read -a array <<< "$roles"
   for i in "${array[@]}"
   do
      number=$(awk -v role="$i" -F '\t' '$2==role {print $1}' role_info.txt)
      if [[ -n $number ]]
      then
         echo "insert into user_roles(user_id, role_id, version) values('$user_id', $number', 1);" >> role_adds.sql
      else
         echo "$i - $user_id" >> bad_roles.txt
         sort bad_roles.txt >> bad_roles_temp
         mv bad_roles_temp bad_roles.txt
      fi
   done

   read -a array <<< "$tasks"
   for i in "${array[@]}"
   do
      number=$(awk -v task="$i" -F '\t' '$2==task {print $1}' task_info.txt)
      if [[ -n $number ]]
      then
         echo "insert into membership(user_id, group_id, dbversion) values('$user_id',$number,1);" >> task_adds.sql
      else
         echo "$i - $user_id" >> bad_tasks.txt
         sort bad_tasks.txt > bad_tasks_temp
         mv bad_tasks_temp bad_tasks.txt

      fi
   done

   #Unset delimiter before we scan through next line of our csv file.
   unset IFS
   ((counter++))

done

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tel2Commented:
Well done, Tampajay!
Sorry I was quite harsh in my 2nd post.

BTW, before you fixed it, did you actually try commenting out the roles section and uncomment the tasks section?  If so, did it process all 3 input records, or just 1.
0
TampaJayAuthor Commented:
For some reason nothing worked until I moved the ssh commands outside of the while loop.

You weren't harsh, just direct - nothing wrong with that.
0
tel2Commented:
That's strange about the SSH loop thing, TampaJay.

Sorry to hear my method didn't help in this case.  Hopefully you will find it useful in isolating some kinds of problems in future.
0
TampaJayAuthor Commented:
Figured it out on my own.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.