Jump to content

Running Autoitscripts as one process


Recommended Posts

Hello,

My collegue and I are working on a project to test the performance of certain tasks. The specific tasks are performed by Autoit scripts. Since longterm data is needed, we also wrote a sheduler in Java. This sheduler starts the scripts in certain time periods. This is done by creating new processes in Java.

When an executable is started it seems to start the script and then return imideately. So altough the scripts run properly, the process and the returncode is lost for Java. For Java the executable is started and finished right away.(When we start the executable in the DOS Prompt, we can see the same behavior. The script runs properly, but the DOS Prompt is aviable right away, altough the compiled script is stil running. When we want to set returncode with exit cannot access the code with %ERRORLEVEL% neither).

What we need is the compiled script running as one process or some way to indicate that the execution of the script is finished. Our current workaround is, that we wait until the performance data is written into a temporary file and then mark the script as finished. Is there another way of doing it?

We use Autoit3 ver 1.7. and work on a WinXP Pro SP2 Machine.

Thanks in advance for your help,

Benjamin and Nico

P.S.: Our Autoit experience is very low. We use it for 4 weeks now.

Link to comment
Share on other sites

Hi,

what do you want? I mean, what should Autoit do so that you can catch it?

May habe a look at OnAutoitExit()

Edit: Or use another Autoit script with RunWait(first script)

You can set the error code in script one with Ecit(100) or Exit(0)

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

what do you want?

We observe, that a compiled script, that is executed in the DOS Prompt is started and the control is imediately turned back to the Prompt. The Script, however, is still executed. It is running in the background somehow. The behavior in Java is exactly the same. The script is executed, but Java thinks the script is finished imediately too.

We need a script, that gives the control back to the DOS-Prompt (or shows Java that the process has ended for that matter) only if the script really has ended!

Link to comment
Share on other sites

HI,

still do not get the problem. :"> if you run a compiled Autoit script the scriptName.exe appears in taskmanager.

You can easily check for the running process.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

if you run a compiled Autoit script the scriptName.exe appears in taskmanager.

That is, of course, true. I apologize, if I did not make myself clear (English is not my native language though). The sheduler starts the scripts and then waits until the process is finished. The process, however, is finished right away (just like the control is turned back to the DOS-Prompt), but the compiled script is running (just not as the process we got with the sheduler). Is there any way to make the compiled skript "not run in the background" or "not turn the control back imedeately"?

Why not code your scheduler in AutoIt and use RunWait for the tasks?

Since we are more experienced in Java than in Autoit and we also need to send the data to a Database, Java was our first choice. Is there a way of connecting to a database (Oracle in our case) with autoit?

Also TimerInit and TimerDiff to time how long it takes to run the task.

In fact, we use this in the scripts to evaluate the duration of certain tasks.
Link to comment
Share on other sites

Hi,

why using the scheduler? If it is a test-system, you can let the Autoit script idle around until a certain Process exists or a HH:MM:SS clock is reached ...

Sometimes there are problems running scripts while pc is locked. You can avoid it by e.g. locking the pc yourself with Autoit. :whistle:

You can use SQL. Search for it.

To evaluate duration : Then TimerDiff is the best, I think.

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

If Java support standard streams, you can use ConsoleWrite to output your data into Java.

Java does support standard streams. We wanted to use the streams to send the data 'directly' to the database, without saving it in a temporary file. However, we find the same problem as described above: Although we can use the i/o streams, they are useless, because the script is started and then executed as some other process (see above).
Link to comment
Share on other sites

Java does support standard streams. We wanted to use the streams to send the data 'directly' to the database, without saving it in a temporary file. However, we find the same problem as described above: Although we can use the i/o streams, they are useless, because the script is started and then executed as some other process (see above).

I see. So now you're going to make AutoIt write values into a file, and let Java check the filesize or wether the file exists, and read it from that file to send it to the oracle database?

Link to comment
Share on other sites

I see. So now you're going to make AutoIt write values into a file, and let Java check the filesize or wether the file exists, and read it from that file to send it to the oracle database?

We have a Java program that does the following things:

1. Parse a file which contains the paths to the scripts and the delay between the executions

2. Manage all entries from the file described in 1. in a thread pool and execute them according to their delay time

3.Write the data gathered from the scripts to a database

In (2.) the script indicates that it is finished by writing its data to a file (Java checks, if the file has changed). In (3.) we parse the file with the data and then write it to the database. It would be some much easier and more secure if we can access the data and the status of the script directly.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...