How to call ODI Scenario from command line and wait for its execution - oracle

I'd like to call an ODI Scenario from command line and wait until its done. I am using ODI 12c and installed a standalone agent. I already found out that you can use the startscen.cmd command and it works for me. The only problem is that cmd is not waiting for the scenario to be done. Any Suggestions to achieve sth like that?
My .bat-file looks like this:
cd C:\Oracle\Middleware\Oracle_Home\user_projects\domains\base_domain\bin
call startScen.cmd "-INSTANCE=CITestAgent" MAPPING 1_0_0 GLOBAL "-SESSION_NAME=TEST_RUN" "-AGENT-URL=http://localhost:20910/oraclediagent"
cd C:\Users\Redekera\documents\testFiles
"C:\Users\REDEKERA\Documents\instantclient_19_3\sqlplus.exe" db_user/pw#db/scheme #run_tests_lieferschein.sql
After that command i'd like to run an sql via sql*plus, which needs to wait until the scenario has finished.
Thanks for help guys :)

By default startscen.cmd will wait for the end of the execution to return.
This can be changed with parameter -ASYNC=yes to start the execution asynchronously. In that case it would return the SESSION number that is useful to check the status of execution.

If you want the second command to execute only if the first exited successfully:
execute scenario command && sql*plus command
Extracted from here
The main idea is the “&&” sign!

Related

Jenkins always SUCCESS state when the Shell script actually failed

I'm facing this challenge in my current Jenkins setup. Where the set of cases like Shell(bash) script executed remotely:
Permission denied while my installer copied
Unable to connect with SSH
Any suggestion on these cases how can I fix it? any pointers?
Thanks in advance
A pipeline will fail if a script / software returns a value not equal zero. There are programs like Robocopy that execute a command, fail and return a 0. Jenkins does not understand that the program was not successful and marks the pipeline as a success.
Basically this is what you have to do. If your script returns a value not equal zero the pipeline will fail.

How to run a command after a certain time while another command is running?

I have a bash script which will be running a main command, let's say for one hour. I would like to execute another command after a certain time since the main command has been started (at t_x). Something like this:
main starts -------> main ends
|
|
at time t_x, second command is executed
At the moment I have something like this:
mpirun main_command & sleep 1m && second_command
and the problem is that after second command is executed, the main command is killed. Can anyone help me? Thanks!
The first command is failing to lock the console, as another process is also using it. You will need to redirect the standard io pipelines, 0<&- mpirun main_command >/dev/null 2>/dev/null If this still does not work, use shell -c 'mpirun main_command' & sleep 1m;second_command You can use ; instead of &&, unless you need a failing exit code when someone interrupts the sleep.

Chain dependent bash commands

I'm trying to chain together two commands:
The first in which I start up postgres
The second in which I run a command meant for postgres(a benchmark, in this case)
As far as I know, the '||', ';', and '&/&&' operators all require that the first command terminate or exit somehow. This isn't the case with a server that's been started, so I'm not sure how to proceed. I can't run the two completely in parallel, as the server has to be started.
Thanks for the help!
I would recommend something along the lines of the following in a single bash script:
Start the Postgres server via a command like /etc/init.d/postgresql start or similar
Sleep for a period of time to give the server time to startup; perhaps a minute or two
Then run a psql command that connects to the server to test its up-ness
Tie that command together with your benchmark via &&, so it completes only if the psql command completes (depending on the exact return codes from psql, you may need to inspect the output from the command instead of the return code). The command run via psql would best be a simple query that connects to the server and returns a simple value that can be cross-checked.
Edit in response to comment from OP:
It depends on what you want to benchmark. If you just want to benchmark a command after the server has started, and don't want to restart the server every time, then I would tweak the code to run the psql up-ness test in a separate block, starting the server if not up, and then afterward, run the benchmark test command unconditionally.
If you do want to start the server up fresh each time (to test cold-start performance, or similar), then I would add another command after the benchmarked command to shutdown the server, and then sleep, re-running the test command to check for up-ness (where this time no up-ness is expected).
In other case you should be able to run the script multiple times.
A slight aside: If your test is destructive (that is, it writes to the DB), you may want to consider dumping a "clean" copy of the DB -- that is, the DB in its pre-test state -- and then creating a fresh DB, with a different name from the original, using that dump with each run of the script, dropping it beforehand.

What is the shell command for waiting the service to finish starting?

I need a simple batch command which will wait until specified service (actually, SQL Server) is finished starting. See, the bat file runs some non-service executables which attemp to connect to the SQL server on start. And they fail.
I tried to help (" /?" key) some Windows Shell commands but they do not seem to respond with an action I need.
Unfortunately, this command doesn't exist. The sc can start and stop a service and it can query the status of a service (see this answer). But even when you query, you will only get "Service is running"; there is no way to tell how far the service got in its startup.
There are two workarounds:
Sleep for a while
Run a simple SQL command in a loop
The first approach will help but it won't completely solve the problem; when the server is under load, the startup can take longer.
For the second approach, use a loop which times out (pseudocode):
Set counter to X
Try to connect
If connect succeeded, exit with success
Decrement counter
If counter <= 0 -> ERROR
Sleep 1s
Go to step 2
For additional safety, you could add a sc query in there to make sure the service didn't fail.

JDBC Batch update

IF i have say 1000 statements in a batch.If one of the command fails to execute properly then will all the remaining commands execute or execution stops at that point itself??
Execution stops at that point. Read this post for a solution/workaround : BatchUpdateException: the batch will not terminate

Resources