Jump to content

Automate my script?


Xenos
 Share

Recommended Posts

Hello! Me again!

I was hoping somebody could help me automate my script?

Basically I run a Daily Status report on some servers to check and log errors. As it is; it is prompting the user to enter "How many days do you want to run your report?" Since the response usually hinges on the day of the week (ie: Monday we run for 3 days, most others just 1) I was hoping to take out the required user input, automate the script, then make it a scheduled task.

Here is the relevant sections of code. I was thinking just replace the Input with a function to get the day of the week. I see in the new datenew.au3 there are several functions that might work with this, but since I am still a raw newbie I was hoping somebody would hold my hand :)

$ANSWER = InputBox("Get Status", "How many days do you want to check?", "2", "", -1, -1)

If @error = 1 Then Exit

If $ANSWER > 5 Then

MsgBox(4096, "Number of Days to Check", "A maximum of 5 Days maybe entered")

$ANSWER = InputBox("Get Status", "How many days do you want to check?", "2", "", -1, -1)

EndIf

If $ANSWER > 5 Then Exit

$Z = $ANSWER + 1

Do

$I = $I + 1

{Processing Here}

Until $I = $ANSWER

If I could have $ANSWER be set automatically based on a GetDayofWeek function.

I really appreciate your help. You guys rule.

Newbs

Link to comment
Share on other sites

You can also search the forums for the datenew.au3 include file.  It contains many good date calculation functions.

<{POST_SNAPBACK}>

Yes thank you both very much. I did not see the WDAY macro. I do have the datenew.au3 file and have isolated the 2 functions that find the day. I am just not quite sure how to implement them. I am still quite new to this - I came from the IT admin world not a programming environment.

So, to implement the macro I would simply ditch the User Input for

If @WDAY = 1 then

$ANSWER = 3 ;Monday - run report for 3 days

else if @WDAY = 6 or 7 ;Sat or Sun do not run report

$ANSWER = 0 ;its a weekday do it for 1 day

else

$ANSWER = 1

end if

end if

endif

Do

$I = $I + 1

{processing}

Until $I = $ANSWER

Thanks so much .. currently I get up at 5AM to run these before production starts. I cant schedule task because of this *1* user input screen. If can make it decide on its own how many days to run then I can make it a scheduled task.

Keep the help coming please.

Newb

Link to comment
Share on other sites

Well, you're mixing your programming forms.... but yeah.

To use the datenew functions, put this at the top of your program. :lmao:

#include <datenew.au3>

Oh, and use the [ code ] [ /code ] or the [ codebox ] [ /codebox ] tags around your code entry. It will preserve the formatting (extra spaces and such) if you cut and paste from something like SciTE.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Well, you're mixing your programming forms.... but yeah. 

To use the datenew functions, put this at the top of your program.  :lmao:

#include <datenew.au3>

Oh, and use the [ code ] [ /code ] or the [ codebox ] [ /codebox ]  tags around your code entry.  It will preserve the formatting (extra spaces and such) if you cut and paste from something like SciTE.

<{POST_SNAPBACK}>

Thank you so much for your help!

Do I need to compile the datenew.au3 when I creaty my EXE file if I use the include?

So I put the include then I can just call the functions by name (ie _GetDateDayofWeek)

So then it would be like

$ANSWER = _DateDayOfWeek

I am trying to follow .. thank you for your patience.

Newb who loves this forum

Link to comment
Share on other sites

Any includes get compiled with the code. Similar to VB or C++ programming yes?

Think of the includes as a container for any functions you're using.

All my code that I write contains no Func statments, only the function calls themsleves. All Func definitions are contained in separate files. That allows me to write programs that call any function I've created for whatever I'm doing. I don't have to re-write each function every time.

So I put the include then I can just call the functions by name (ie _GetDateDayofWeek)

So then it would be like

$ANSWER = _DateDayOfWeek

I am trying to follow .. thank you for your patience.

Yes. read the help file about the #include statement.

Also, any file you want to #include, make sure it has an #include-once statement.

Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Link to comment
Share on other sites

Any includes get compiled with the code.    Similar to VB or C++ programming yes? 

Think of the includes as a container for any functions you're using. 

All my code that I write contains no Func statments, only the function calls themsleves.  All Func definitions are contained in separate files.  That allows me to write programs that call any function I've created for whatever I'm doing.  I don't have to re-write each function every time.

Yes.  read the help file about the #include statement. 

Also, any file you want to #include, make sure it has an #include-once statement.

<{POST_SNAPBACK}>

ALL HAIL THE DRAGON!
Link to comment
Share on other sites

Ok I have modifying the script and now I am having a SAVAGE error when I try to run the compiled EXE

I will post the code modifications and the error I get. Any help is REALLY appreciated.

CODE

If @WDAY = 2 Then

$ANSWER = 3 Else

If @WDAY > 2 AND @WDAY < 7 Then

$ANSWER = 1

EndIf

EndIf

.

.

.

Do

$I = $I + 1

{processing}

Until $I = $ANSWER

Now this is the worst error I have ever seen.

16 bit MS-DOS Subsystem MsgBox (Close/Ignore)

The NTVDM CPU has encountered an illegal instruction.

CS:0dc5 IP:0146 OP:63 61 6c 20 24 Choose 'Close' to Terminate

Now what the hell have I done?

Manual script runs fine and all I have done is replaced the User Input (How many days..") with the above chunk.

Anything?

Panicked Newb

Link to comment
Share on other sites

Ok I have modifying the script and now I am having a SAVAGE error when I try to run the compiled EXE

I will post the code modifications and the error I get. Any help is REALLY appreciated.

CODE

If @WDAY = 2 Then

    $ANSWER = 3 Else

    If @WDAY > 2 AND @WDAY < 7 Then

    $ANSWER = 1

    EndIf

EndIf

.

.

.

Do

$I = $I + 1

{processing}

Until $I = $ANSWER

Now this is the worst error I have ever seen.

16 bit MS-DOS Subsystem MsgBox (Close/Ignore)

The NTVDM CPU has encountered an illegal instruction.

CS:0dc5 IP:0146 OP:63 61 6c 20 24 Choose 'Close' to Terminate

Now what the hell have I done?

Manual script runs fine and all I have done is replaced the User Input (How many days..") with the above chunk.

Anything?

Panicked Newb

<{POST_SNAPBACK}>

Maybe it is because you need to initialise $I to zero before you start the Do/Until loop.

$I = 0

Do

blhblh

until $I = $answer

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Maybe it is because you need to initialise $I to zero before you start the Do/Until loop.

$I = 0

Do

blhblh

until $I = $answer

<{POST_SNAPBACK}>

I have made this change, however I don't think that is the problem. The original script had the same Do with the $I uninitialized.

This really should be easy but I am still having problems. There is a massive script and all I am changing is

$ANSWER = InputBox blah blah

to

$ANSWER = 1
If @WDAY = 2 then
   $ANSER = 3
end if

Then I am going to schedule the task in Task Scheduler (W2K) to run M-F (no weekends)

I will get back to you once I test my new compile.

Thanks again!

Newbie

$ANSWER = 1

If @WDAY = 2 then

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