Shell Script executing Oracle PL/SQL code - shell

I'm calling a PL/SQL code from shell script which takes time to finish, but after completion of PL/SQL code the shell script session is not terminated and also still shows as active when is type ps -aef|grep 'SQL*PLUS'. Any suggestion why the shell script session is not terminated.
Note : PL/SQL code has no issue and ran successfully. I have used cron job to run the shell script.
The shell script is terminated when Data is less to process.

Related

How to avoid series of commands running under sql plus using shell script

I have created a script which runs a series of other instances in shell using the while command. But the problem is that one of the job is connecting to sql plus and running the remaining command under sqlplus.
For ex. my input file --> job.txt
job1
job2
job3
Now, using the below script I am calling job one by one. So, until the present job is finished next job wont start. But the catch comes when the job tries to connect the sql plus. After it connects to sql plus, the process id of the current job gets complete and remaining jobs run as the sql statement in unix env.
while read line;
do
$job1
done < job.txt;
Error message I am getting in sqlplus after current instance exits.
SP2-0042: unknown command
How can I avoid bringing the jobs under sqlplus.

How do I embed an expect script within a bash script so the shell I open doesn't close after the expect script finishes?

I've been writing Bash scripts that work with a database lately.
To access the database, I need to ssh into a DiskStation (requires password) and then sudo a docker command (requires password) to access the container that the database is in. Only then can I execute and test out my scripts.
I wrote an expect script that automates this process and I want to embed it in my Bash scripts, but the only problem is the shell closes as soon as the expect script finishes executing.
Does anybody know how to work around this? I attached a photo with specific info removed. Bash script with embedded expect script

How to create a job in shell script?

I know that execute a command and add & to the end would create a job and make the command execute in background.
Now I want to create a job in a bash shell. I tried
#!/bin/bash
my-job &
# some other tasks
Then I executed jobs, but I got no output. However, ps aux does show my-job is running in the background.
I want to create a job inside a script, because in some cases I want to bring the job into foreground.
jobs are usually an interactive shell concept, as there is usually a controlling terminal involved.
A shell script is executed in a non-interactive, non-login session of shell, hence no job control by default.
You can force job control inside a script, by setting:
set -m
inside the script.
From help set:
-m Job control is enabled.

Why does scheduling Spark jobs through cron fail (while the same command works when executed on terminal)?

I am trying to schedule a spark job using cron.
I have made a shell script and it executes well on the terminal.
However, when I execute the script using cron it gives me insufficient memory to start JVM thread error.
Every time I start the script using terminal there is no issue. This issue comes when the script starts with cron.
Kindly if you could suggest something.

Terminate shell script if stored proc fails, to capture status in my autosys job

I have Korn script that executes my SQL stored proc. My Autosys job invokes this script. I want to capture the status of the stored proc in my autosys job. Right now even if my stored proc fails, autosys captures success since the shell script succeeds(i can capture teh error in script but the script it self doesn't fail). How do i fail the script if my stored proc fails and therefore fail the autosys job.
Exit with a non-zero return code, e.g.
exit 1

Resources