title: Send result of SQL procedure in a file with a script sh
body: <p>I have a SQL procedure in a file and I would like to call this procedure in a sh script then send the result in a file (no matter where is the file).</p>
  
  <p>I do not know if I am doing well or not but here what I wrote :</p>
  
  <pre><code>#!/bin/ksh
  #exit 0
  
  VAR=$(sqlplus /NOLOG &lt;&lt;!
  connect E760/E760@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST=p595n11)(PORT=1521))(CONNECT_DATA = (SID = DBUVNSD5)))@PA_IND_DELAYS_BODY.sql;
  !)
  
  result=`sqlplus / &lt;&lt;SCRIPT| grep ^result | sed "s/^result: //"
  set serveroutput on
  declare
      var_truc_result VARCHAR2(255);
  begin
     export_csv('$1','$2');
     dbms_output.put_line( 'result: ' || var_truc_result);
  end;
  /
  exit
  SCRIPT`
  
  sqlplus "system/ADMIN" &lt;&lt;!
  exec export_csv($0,$1);
  !
  
  echo var_truc_result is: "$result"
  </code></pre>