Jump to content

Error finding


 Share

Recommended Posts

Hi,

Need clarification. If I run a script to perform a repetitive task in Hidden/Invisible mode, how will I know if the script is still running without any problem or if the script has stopped/failed in between? Is there a way that I will be informed via Outlook mail or via Toast message or using msgbox?

Link to comment
Share on other sites

there are several ways:

1) by exit code:

if a script crashed, or killed by Task Manager, a typical exit code is 1. you can use that depending on how you launch your script. for example, if it's by another script, then that script can set an alarm if exit code is 1 (or other than zero). that's the closest you can get to passive monitoring.

2) by active monitor - main script presence:

set another script to run constantly in the background, hooked to the processes list. if it detects an event that the main script is gone from the processes list, it can set an alarm.

3) by active monitor - main script log/flag:

have the main script log it's activity, or raise a flag ("touch" a file) every few seconds. set a monitoring script to check the "modify" timestamp of the log file or flag, and set an alarm if it's older than those few seconds (or 2x few seconds, to be safe).

4) by pending alarm:

create a scheduled task that will alarm you in 2x few seconds. have your script re-schedule that scheduled task every few seconds. so if the script fails, the alarm will not be re-scheduled and will fire in 2x few seconds.

my favorite method is (1), but that depends on the specific situation.

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

there are several ways:

1) by exit code:

if a script crashed, or killed by Task Manager, a typical exit code is 1. you can use that depending on how you launch your script. for example, if it's by another script, then that script can set an alarm if exit code is 1 (or other than zero). that's the closest you can get to passive monitoring.

2) by active monitor - main script presence:

set another script to run constantly in the background, hooked to the processes list. if it detects an event that the main script is gone from the processes list, it can set an alarm.

3) by active monitor - main script log/flag:

have the main script log it's activity, or raise a flag ("touch" a file) every few seconds. set a monitoring script to check the "modify" timestamp of the log file or flag, and set an alarm if it's older than those few seconds (or 2x few seconds, to be safe).

4) by pending alarm:

create a scheduled task that will alarm you in 2x few seconds. have your script re-schedule that scheduled task every few seconds. so if the script fails, the alarm will not be re-scheduled and will fire in 2x few seconds.

my favorite method is (1), but that depends on the specific situation.

 

Thanks Orbs. Method (1) would be more appropriate. How to achieve this? Can you show the code part? Thanks.

Link to comment
Share on other sites

as i said, that depends on how you launch your script. so, how do you launch your script?

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

yes, that's what i mean. but in this case, if the script crash, it will report the exit code of 1 to the Windows shell (explorer.exe). you can not program explorer.exe to handle it - at least not without additional scripting, which is basically what methods (2) and (3) do.

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

yes, that's what i mean. but in this case, if the script crash, it will report the exit code of 1 to the Windows shell (explorer.exe). you can not program explorer.exe to handle it - at least not without additional scripting, which is basically what methods (2) and (3) do.

 

Can you show the way to perform this using method (2)?

Link to comment
Share on other sites

try here:

'?do=embed' frameborder='0' data-embedContent>>

the "Best Answer" code works as is. it is configured to write to console every event of a process start or end. you can customize it for specific process and fire any alarm.

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

you have to run it as an independent parallel script, because if the main script crash, then its own monitoring capability is also crashed.

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

you have to run it as an independent parallel script, because if the main script crash, then its own monitoring capability is also crashed.

 

Yup. I guessed so. So if I run the main script, it should trigger this parallel script as well to monitor the process change, right?

Link to comment
Share on other sites

up to you. you can either have the main script launch the monitoring script before it starts, but then if it crash and you re-launch it, make sure you do not have the monitoring script re-launched too, because the monitoring script itself did not crash, or have the monitoring script automatically launched at startup.

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

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