Sign in to follow this  
Followers 0
skyhigh

Restart a script

8 posts in this topic

I am working on a script.
This script operates on a program.
What happens if the program crashes? The script stops.
For this reason I have to work a secondary script out whose task is to check if the program runs.

The problem is, I need to add also a comand in the secondary script that restarts the primary script. How can I do it?


Thanks in advance

Share this post


Link to post
Share on other sites



2 hours ago, skyhigh said:

What happens if the program crashes? The script stops.

and why is that?

Share this post


Link to post
Share on other sites

Show your 2 scripts so we get able to help you.  

Share this post


Link to post
Share on other sites

While Loop + If ProcessExists()

Are your scripts compiled or being run as .au3?

Share this post


Link to post
Share on other sites
6 hours ago, orbs said:

and why is that?

 

6 hours ago, ViciousXUSMC said:

While Loop + If ProcessExists()

Are your scripts compiled or being run as .au3?

The scripts run as .au3.

I have already put a ProcessExists() at each Case, but it does not always work. I need to always check if firefox.exe exists

Here an example of  the main script:

#include <ff.au3>

_FFStart()

While @Hour < 16

Global $aURLS[6]
$aURLS[1] = "www.youtube.com" ; list of youtube, vimeo, etc videos
$aURLS[2] = "www.yahoo.com"
$aURLS[3] = "www.vimeo.com"
$aURLS[4] = "www.dailymotion.com"
$aURLS[5] = "www.twitch.tv"

$x = Random(1, 5, 1)

_FFTabAdd($aURLS[$x], True, True)
WinWaitActive("Tab",0,10)

Sleep(5 * 1000) 

_FFTabClose("0", "index")
Sleep(5000)

  Select
    Case $x = 1
        If Not ProcessExists("firefox.exe") Then _FFStart("www.youtube.com")

    Sleep(15 * 1000) 
   
   Case $x = 2
        If Not ProcessExists("firefox.exe") Then _FFStart("www.yahoo.com")

    Sleep(15 * 1000) 
   

EndSelect

Wend

I'll now try to explain myself a little better:

- The script is able to run thanks to ff.au3 UDFs

- The script must be as indipendent as possible

That is the reason why it is necessary to write on secondary scripts that are able to react if something happens, whenever it happens.

If Firefox crashes I get the following lines in the log:

__FFWaitForRepl ==> MozRepl Exception: !!! [Exception... "Failure"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"

_FFCmd ==> Error return value
.__FFSend ==> Error TCPSend / TCPRecv: TCPSend: try{FFau3.tmp=window.getBrowser().webProgress;FFau3.tmp.isLoadingDocument && FFau3.tmp.busyFlags ? false: true;}catch(e){'_FFCmd_Err';};

Even if Firefox restarts the error continues.

I thought I could solve using some _FFCmd input. Since I created a thread and nobody could help me, a better idea was born:

to write a secondary script to check if the firefox crash report appears, then restart not FF but the script itself

And here I am :)

 

 

 

Share this post


Link to post
Share on other sites

This can't be your complete mainscript and the restartscript is totaly obselet. I think you are downloading videos from the URL's, so more RAM could be usefull.

Share this post


Link to post
Share on other sites

The script is mean to stream videos from different sites, I do not need to download them. 

The main script's structure is the one I posted, I only forgot the _FFQuit at the end.

Share this post


Link to post
Share on other sites
30 minutes ago, skyhigh said:

The main script's structure is the one I posted, I only forgot the _FFQuit at the end.

And where is the restart script?

Share this post


Link to post
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
Sign in to follow this  
Followers 0