Jump to content

Restart a script


skyhigh
 Share

Recommended Posts

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

Link to comment
Share on other sites

2 hours ago, skyhigh said:

What happens if the program crashes? The script stops.

and why is that?

Signature - my forum contributions:

Spoiler

UDF:

LFN - support for long file names (over 260 characters)

InputImpose - impose valid characters in an input control

TimeConvert - convert UTC to/from local time and/or reformat the string representation

AMF - accept multiple files from Windows Explorer context menu

DateDuration -  literal description of the difference between given dates

Apps:

Touch - set the "modified" timestamp of a file to current time

Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes

SPDiff - Single-Pane Text Diff

 

Link to comment
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 :)

 

 

 

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...