Command Line execution

CamiCat

Member
Hello friends,

how is it possible to launch the Command Line Application and execute commands in it?
Thank you so much,
Camilla.
 

Attachments

  • command line.png
    125.4 KB · Views: 294

sivagelli

Well-Known Member
I can think of following ways-

#1. Create an object for launching cmd.exe and Using Global Send Keys to execute the commands.
#2. Use 'Start Process' Action from Environment VBO. For input Path, pass the path of the cmd.exe and for arguments pass the command you want to execute. If you want to execute "DIR", then the input for Arguments should be "/c DIR", the command will be executed and cmd.exe will be closed. If you want to see the command prompt after the execution of the command as well use "/k DIR". This method can be useful if you have to run one command to execute.
#3. If you have a list of commands, you can create a batch job (.bat) and pass the path of the batch file as an argument to the #2

Post back if you have questions!
 

CamiCat

Member
Thank you so much @sivagelli.
How is it possible to create a batch job (.bat) and pass the path of the batch file as an argument to the #2?
Thank you so much,
Camilla
 

CamiCat

Member
Hello @sivagelli,
can you please share me a screenshot of where I can get the tility-UEnvironment VBO" ?
I cannot find it in the list of my objects.
In case can you share my the Object?
Thank yo so much,
Camilla.
 

VJR

Well-Known Member
Hello friends,

how is it possible to launch the Command Line Application and execute commands in it?
Thank you so much,
Camilla.
Which command(s) are you trying to run on the command line and what exactly are you trying to do with it?
 

CamiCat

Member
Hello @VJR ,

I would like to run some commands to connect to a DataBase like:
QUERY:
SELECT distinct a.cod_cliente
FROM associaz_solleciti_doc a
WHERE a.num_pgs_sollecito = [valore];

Can you please tell which is the best way to do it?
Thank you so much,
Camilla :)
 

VJR

Well-Known Member
If you are planning to connect to a database then you can think of using the VBOs specially designed to do so-
- Data - SQL Server (for connecting to SQL Server database)
- Data - OLEDB
You can use either of these depending on the database you have. Both these VBOs have an action where you can provide the SQL query as a parameter provided in your above post.

If you do not find any of these VBOs then you can import it from the Blue Prism installation folder which is usually C:\Program Files\Blue Prism Limited\Blue Prism Automate\VBO.
 

CamiCat

Member
Hello,
have you got an example of workflow developed for connecting to the database through command line execution?
Unfortunately do not find any of these VBOs you advised me.
Can you please kindly provide me them?
Thank you so much,
Camilla :)
 

sivagelli

Well-Known Member
Every database: Oracle, mySQL, SQL, etc., has support for the Command Line interface for executing queries. Just google for usage of the command line terminal for the database you are using; you should be getting the enough documentation online.

For database interactions, BP has built in VBOs which simplifies things for you as the data returned from the sql queries is available as collections to play around. Otherwise, reading the sql query output from the terminal in to BP Data Items or Collections is not straight forward.
 

CamiCat

Member
Hello @sivagelli,

thank you so much for your detailled response and advices.

I would like to run some commands to connect to a DataBase like:
QUERY:
SELECT distinct a.cod_cliente
FROM associaz_solleciti_doc a
WHERE a.num_pgs_sollecito = [valore];

Can you please tell which is the best way to do it?
Thank you so much,
Camilla :)
 

CamiCat

Member
Hello @sivagelli,

after launching the activity 'Start Process' Action from Environment VBO for launching cmd.exe, how is it possible to extract the result of the line execution obtained in the cmd.exe?
Thank you so much,
Camilla :)
 

veldew

New Member
That is not possible with the standard "run proces" vbo, you will need to modify as something like this :



p = New System.Diagnostics.Process()
p.Start()
r = p.StandardOutput

If Time_Out>0 AndAlso p.WaitForExit(1000*Time_Out)=False Then
Throw New Exception("Failed waiting for application to end")
End If

Output = r.ReadToEnd()
 
Top