0

When I try to run a shell script through JSCH, it gives me an error when it tries to call "sqlplus". It will run shell commands and everything fine, but when the script tries to use sqlplus, it stops and won't work. Is there some reason for this with JSCH?

The script will run up until it calls the sqlplus command. The only error it gives is this:

sqlplus: not found

with the line number this occurred on. Is this something with JSCH where it can't run commands within the scripts? Or am I missing something I need to set with the channel?

EDIT: Testing further, it can't actually even run sqlplus outside of the script.

MrDaveForDays
  • 121
  • 1
  • 7

1 Answers1

0

The user you're logging in as with JSCH does not have sqlplus in it's path, so the shell is unable to locate the binary.

It's not a Korn Shell problem, it's an environment problem. Either you must run sqlplus by specifying it's full path on disk, such as /path/to/sqlplus <arguments> or add sqlplus to the environment variable $PATH for the user you're logging in as.

If your script should be portable, then it's common practice to not hard-code the binary path, but rather run through a series of tests to see where the binary is located, checking all common locations for the binary as well as seeing if it's on the path. Once found, set that absolute path to some variable, then use that variable whenever you need to run that binary in your script.

SnakeDoc
  • 13,611
  • 17
  • 65
  • 97