Mysql SELECT is breaking the line to new STACK

Any idea ? whay SELECT is breaking the line to (New STack), I need to use email variable in the mail-s string but due to this I cannot use it, same SQL and mail-s works OK from bash.

[service-noti-email-60010]
exten=> s,1,Noop( checking the callerid ${CALLERID(num)})
same=>n,Set(email=${SHELL(mysql -sN customerinfo -u admin -pPASSWORD -h IPADDRESS -e ‘select email from account where phone=’"${CALLERID(num)}"’ ')})
same=> n,TrySystem(echo “Incoming Call - From: ${CALLERID(name)} ${CALLERID(number)} received at ${STRFTIME(${EPOCH},%l:%M:%S %p %Z on %A %B %e)}” | mail -s “Phone - Incoming Call to MailRoom 6108” “${email}” hello@example.com)

Executing [s@service-noti-email-60010:1] NoOp(“PJSIP/1001_1-0000014e”, " checking the callerid 1001") in new stack
Executing [s@service-noti-email-60010:2] Set(“PJSIP/1001_1-0000014e”, "email=aamir
– ") in new stack
– Executing [s@service-noti-email-60010:3] TrySystem(“PJSIP/1001_1-0000014e”, "echo ‘Incoming Call - From: Test 1001 received at Sun Aug 15 19:05:50 2021’ | mail -s “Phone - Incoming Call to IT 6108” -r “aamir
– " hello@exampl.net”) in new stack
– Auto fallthrough, channel ‘PJSIP/1001_1-0000014e’ status is ‘UNKNOWN’
phone
CLI>

“in new stack” is part of the log message, not the command; it is not relevant to your problem. Your problem appears to be that you have excess characters at the end of the value of the email variable, probably a linefeed.

See the note n the RETURN VALUE section of:

When I execute a command like:

mysql -sN --execute='select email ...;'

I get output like:

+---------------------+
| example@example.com |
+---------------------+

You may want to add

--disable-table

Also, I’d replace ‘-sN’ with:

--disable-column-names --silent

While I use short options on commands I type in shell, anything that somebody else may look at (even me, years later) I use the long options to save the ‘next guy’ a trip to the man page.

1 Like

thanks, I will try these options

I tried this and it worked, no more line breaks

same=>n,Set(mailg=${getemail:0:-1})

I just noticed that ${getemail} variable is keep pulling the old data even the DB has been updated ? is there way to refresh the variable ?

Need a console log with verbose > 2 to see what’s going on.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.