0

I use procmail to filter email which involves retrieve result from mysql, but Procmail recipe returned column name which I don't want and result. variable result is not declared or used before the line: Here is the line in my procmail:

{
 result=`mysql -uuser -ppasscode dbname -e "select raw_data from tablex where id='"$msgID"'`
 result=`echo "$result" 
}

How to trick it/rewrite it not to return raw_data in the result?

tripleee
  • 175,061
  • 34
  • 275
  • 318
Madz Lee
  • 51
  • 2
  • 5

1 Answers1

0

This isn't really a Procmail question. Specifically, for MySQL, the way to get a query result without headers is to use mysql -N -s as detailed in the nominated duplicate question.

In the more general case, you can use arbitrarily complex shell script inside the backticks. To suppress the first line of something, pipe it through tail +2.

result=`mysql ... whatever | tail +2`

The braces are not doing anything useful in this limited context (though if this is the action part of a recipe which you are not showing us, they are necessary there). Similarly, result=`echo "$result"` is not doing anything useful at all, just starting another shell to assign the variable's value back to itself, clumsily.

Community
  • 1
  • 1
tripleee
  • 175,061
  • 34
  • 275
  • 318