0

I have to execute a script in just on row.

Here is my script (simplified version) tt.sh:

result=`sqlplus -s / as sysdba <<EOSQL
set heading off feed off termout off pages 0 lines 150 serveroutput on
select 1 from dual;
EOSQL`
if [ $result = '1' ] ; then echo 'OK'; else echo 'KO'; fi;

When i run the the script, it works:

./tt.sh
OK

Is there a possibility to put the 5 lines of tt.sh in one line?

Thank in advance

jarlh
  • 42,561
  • 8
  • 45
  • 63
eliatou
  • 744
  • 5
  • 12
  • Looks like this is an [XY problem](https://xyproblem.info/): please, describe what you want to achieve and why you want to put everything in one line. Or check [this question about similar problem](https://stackoverflow.com/questions/15580144/how-to-concatenate-multiple-lines-of-output-to-one-line): but do it backwards, replace something with newline (it doesn't matter what is the separator). – astentx Jan 09 '22 at 20:45
  • Hello, Thank for your answer. This is not an XY problem. I 'm forced to run this stupid program in one raw. So please help me if you can. – eliatou Jan 09 '22 at 21:00
  • Might still well be an XY problem. The real problem seems to be that you have to use only one r**o**w (or think so). Maybe you should work on that or tell us the reasons so we can help. – sticky bit Jan 09 '22 at 21:06
  • I need to insert this code into a screen. Scripts played in this screen must absolutely be on one line. This is really not an XY problem :) – eliatou Jan 09 '22 at 21:13
  • What does "insert this code into a screen" mean? – AKX Jan 09 '22 at 21:41
  • Listen, In my company, I have to run this script in this tool. It does not allow me to go to the line. So help me if you can. thanks in advance. – eliatou Jan 09 '22 at 22:25
  • thank for your response: syntax error ar line ; 'then' unexpected U have errors on brackets – eliatou Jan 09 '22 at 23:50
  • 1
    If for whatever reason you are limited to one line, create a script with multiple lines, give execute permission, invoke the script, it would be only one line – Diego Torres Milano Jan 10 '22 at 00:56

1 Answers1

0

If there is a problem 'ORA-' will occur.

sqlplus -L -S / as sysdba < /dev/null |grep 'ORA-'; if [[ $$? == 1 ]]; then echo 'KO'; else echo 'OK'; fi

Best of luck!

Bjarte Brandt
  • 4,191
  • 2
  • 23
  • 25