title: libreadline undefined symbol: PC in bash when using | bc -l
body: <p>I am connecting by <code>ssh</code> to another machine to execute a bash script, whose problematic part is the following:</p>
  
  <pre><code>fkeypar "ex1.fef[1]" TSTARTI         #### fkeypar is an external command to get some values to assign to the subsequent variables
  t0i="$(expr $(pget fkeypar value) - 11544)"                                          
  fkeypar "ex1lc.fits[2]" TELAPSE
  lengthini=`pget fkeypar value`
  fkeypar "ex7lc.fits[2]" TSTOP
  lengthfin=`pget fkeypar value`
  fkeypar "ex1lc.fits[2]" TSTART      
  ijd=`pget fkeypar value`
  
  i=$(echo "($ijd - $t0i) / $period + 1" | bc -l | sed 's/\..*//')
  ifin=$(echo "($lengthfin - $ijd)/$period + 1" | bc -l | sed 's/\..*//')
  echo "($ijd - $t0i) / $period + 1" | bc
  
  for ((n=$i; n&lt;=$ifin; n++))
  do
     ...
  </code></pre>
  
  <p>This returns the following errors:</p>
  
  <pre><code>bc: symbol lookup error: /science/heasoft-6.14/x86_64-unknown-linux-gnu-libc2.9/lib/libreadline.so.6: undefined symbol: PC
  bc: symbol lookup error: /science/heasoft-6.14/x86_64-unknown-linux-gnu-libc2.9/lib/libreadline.so.6: undefined symbol: PC
  bc: symbol lookup error: /science/heasoft-6.14/x86_64-unknown-linux-gnu-libc2.9/lib/libreadline.so.6: undefined symbol: PC
  ./script: line 39: ((: n=: syntax error: operand expected (error token is "=")
  </code></pre>
  
  <p>Googling A LOT, I found that i very related with these "bugs":
  <a href="https://science.nrao.edu/forums/viewtopic.php?f=44&amp;t=75" rel="nofollow noreferrer">https://science.nrao.edu/forums/viewtopic.php?f=44&amp;t=75</a></p>
  
  <p><a href="https://bugzilla.redhat.com/show_bug.cgi?id=162023" rel="nofollow noreferrer">https://bugzilla.redhat.com/show_bug.cgi?id=162023</a></p>
  
  <p><a href="https://dba.stackexchange.com/questions/31143/libreadline-so-6">https://dba.stackexchange.com/questions/31143/libreadline-so-6</a></p>
  
  <p>I don't have any idea on how to fix it, without trying random things. Any help really appreciated.</p>
  
  <p>EDIT: I forgot to mention that, in my many trials, ssh-ing many times, I managed somehow to do not get the error and run the script, with the same syntax as reported in the question. At that moment, I thought it was a syntax problem, but then the error appeared again at consequent ssh-ings.</p>
  
  <p>EDIT2: IT doesn't matter what version of <code>heasoft</code> I load, the error always appears for the <code>heasoft-6.14</code> version. I think this is related to a possible fix.</p>