cancel
Showing results for 
Search instead for 
Did you mean: 

How to obtain process object of just launched cmd

SOLVED
Highlighted
Occasional Contributor

How to obtain process object of just launched cmd

Hi there,

I have one cmd instance launched (#1), and then I run one more instance (#2):

 

    var obj = Sys.OleObject("WScript.Shell")
    obj.Run("C:\\Users\\admin\\run_sql.bat")

After it I need to obtain run_sql.bat output. I do following:

 

    var p = Sys.Process("cmd");
    var w = p.Window("ConsoleWindowClass", "*");
    var txt = w.wText;

But I get output of cmd instance #1 instead of just created instance.

Please help me to get correct process object

2 ACCEPTED SOLUTIONS

Accepted Solutions
Community Hero

Re: How to obtain process object of just launched cmd

When you try to run your PL/SQL script in test complete via an ADO connection and it fails, what is the failure you are seeing? Perhaps we can more easily work that out and you would then have a more robust way of generating your orders with parameters? 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped

View solution in original post

Occasional Contributor

Re: How to obtain process object of just launched cmd

I found out that ADO connection can`t work with multiple PL/SQL blocks in one script. Like this:

variable a  number;
variable b  number;

def a = x;
def a = y;

begin
....
end;
/

begin
....
end;
/

So I changed this to:

declare
a  number := x ;
b  number := y ;

begin

begin
....
end;


begin
....
end;

end;

And it helped! Now I can run my script via ADO, so I don`t need to run shell.

Thanks for all advices!

 

View solution in original post

6 REPLIES 6
Community Hero

Re: How to obtain process object of just launched cmd

I would add your run_bat as a TestedApp in your project and then call the TestedApp Run method to execute it.  That method returns the process that was just created.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Community Hero

Re: How to obtain process object of just launched cmd

Not sure if Poweshell would be an option, but you can actually grab output from ps scripts without interacting with the window itself:

 

https://support.smartbear.com/testcomplete/docs/testing-with/advanced/using-external-functions/runni...

 

Also, the script being called run_sql, are you just performing some type of queries? That would be better handled using an ADO connection directly inside of test complete. 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped
Occasional Contributor

Re: How to obtain process object of just launched cmd

tristaanogre, cunderw, thanks a lot!

 

Actually these are my first steps in automation testing, some my decisions can be really silly.

 

I'll try to explain what I want to do.

I have complex PL/SQL scipt with many 'begin' blocks and script variables. This script creates invoice in Oracle EBS and performs few more actions.

Off curse it would be great for me to run this script via ADO connection, I have all prepared structure for it. But it fails. I tried whole day to run it, I looked for decisions here and in google, but now I`m not sure it is possible.

So I installed SQL*PLUS and created .bat file which will run that PL/SQL scipt. And now I`m trying to run it using SQL*PLUS. Also there are parameters in this script, and actually I want to have ability to change them... But now I hardcoded all parameters and just try to run script and get output.

In output of script there is generated name of created invoice. I need it for further work. So I need to obtain output somehow.

 

Well, that`s it. Maybe you can suggest some new decision for my goals. Thanks!

 

P.S. Sorry for my english, hope you will understand this text Smiley Happy

Community Hero

Re: How to obtain process object of just launched cmd

When you try to run your PL/SQL script in test complete via an ADO connection and it fails, what is the failure you are seeing? Perhaps we can more easily work that out and you would then have a more robust way of generating your orders with parameters? 


Thanks,
Carson

Click the Accept as Solution button if my answer has helped

View solution in original post

Occasional Contributor

Re: How to obtain process object of just launched cmd

I found out that ADO connection can`t work with multiple PL/SQL blocks in one script. Like this:

variable a  number;
variable b  number;

def a = x;
def a = y;

begin
....
end;
/

begin
....
end;
/

So I changed this to:

declare
a  number := x ;
b  number := y ;

begin

begin
....
end;


begin
....
end;

end;

And it helped! Now I can run my script via ADO, so I don`t need to run shell.

Thanks for all advices!

 

View solution in original post

Community Hero

Re: How to obtain process object of just launched cmd

Hi,

 

While it may be too late already, but just for your record: https://support.smartbear.com/viewarticle/8963/

Regards,
Alex
[Community Expert Group]
____
[Community Expert Group] members are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Postings made by [Community Expert Group] members
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
[Community Expert Group] signature is used with permission by SmartBear Software.
http://smartbear.com/forums/f83/t86934/community-experts/
================================
New Here?
Join us and watch the welcome video:
Watch the new Interview