-3

I am working on two servers one is oracle database and another is linux , first of all i exported path of oracle server and later i want to process the output and it is showing bash command not found error , I tried with exporting bash profile too Below is what i have done as far :

#!/bin/bash
export ORACLE_HOME=/Oracle/app/oracle/product/11.2.0.2/db_1 
export PATH=/Oracle/app/oracle/product/11.2.0.2/db_1/bin:.
sqlplus system@xe/oracle123 << EOF >home/cron.log
@/home/test.sql > /home/zoutput/test.txt
EOF

echo "This is test"

error: syntax error near unexpected token `"This is test"'

#!/bin/bash
export ORACLE_HOME=/Oracle/app/oracle/product/11.2.0.2/db_1 
export PATH=/Oracle/app/oracle/product/11.2.0.2/db_1/bin:.
sqlplus system@xe/oracle123 << EOF >home/cron.log
@/home/test.sql > /home/zoutput/test.txt
EOF

echo("This is test")
cut -c-3 /Backend/home/zoutput/test.txt|sort |uniq 
>/Backend/home/zoutput/test2.txt

ERROR cut,sort,uniq command not found

Suman
  • 160
  • 1
  • 9
  • What do you think your script should do? – Mad Physicist May 16 '19 at 04:28
  • 1
    Did you mean to trash the pre-existing path completely? – Mad Physicist May 16 '19 at 04:29
  • After EOF command clearly DID run as it produced a syntax error. Run your script through shellcheck (e.g. http://shellcheck.net), fix the errors and then let us know if you still have questions. – Ed Morton May 16 '19 at 04:32
  • The main problem is after EOF any linux command it is not taking properly , what the heck happend with EOF i don't know @MadPhysicist – Suman May 16 '19 at 04:38
  • 1
    Duplicate of https://stackoverflow.com/questions/5642521/command-not-found-error-in-bash-script – tripleee May 16 '19 at 04:51
  • Possible duplicate of [command not found error in bash script](https://stackoverflow.com/questions/5642521/command-not-found-error-in-bash-script) – Shawn May 16 '19 at 05:02
  • I didn't found out any solution from that question @tripleee – Suman May 16 '19 at 05:24
  • i didn't find any solution and it is as duplicate @Shawn – Suman May 16 '19 at 05:24
  • When you override `PATH` like that, you basically disable all external commands. The system directories `/bin`, `/usr/bin` etc need to be on your `PATH` in order for e.g. `cat` or `ls` to work. (`echo` is a bad example because it's a shell builtin; but of course, as the answer you got already states, your syntax is horribly wrong.) – tripleee May 16 '19 at 05:26
  • Look at your code closer, then. See where you set `PATH`? – Shawn May 16 '19 at 05:30
  • Can i export a new path as export $PATH =/home/zoutput/ for below lines (*to_make_use_of_cut*) appending new path after EOF (can i do that ?) @Shawn – Suman May 16 '19 at 05:35
  • Why are you *replacing* the path at all? – Shawn May 16 '19 at 06:38
  • i need to communicate with different server so i need to set another path for that @Shawn – Suman May 16 '19 at 06:39

1 Answers1

2

use echo without parentheses!

echo "This is test"
Keith Thompson
  • 254,901
  • 44
  • 429
  • 631
UtLox
  • 3,744
  • 2
  • 10
  • 13
  • cut -c-3 /home/zoutput/test.txt|sort |uniq >/home/zoutput/test2.txt (*after that line it is showing cut command not found* , I have a next cut_line command after that , soley this command is working but inside here it is not working) – Suman May 16 '19 at 04:46