Newbie Help Plz, trying to get Macro Sched to.....

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
zodemere
Newbie
Posts: 8
Joined: Wed Jul 21, 2004 9:06 pm

Newbie Help Plz, trying to get Macro Sched to.....

Post by zodemere » Wed Jul 21, 2004 9:11 pm

Newbie Help Plz, trying to get Macro Sched to dectect when I lose my dialup internet connection and then run a macro that will run the ISP software I have to use to get back on the internet and then continue to wait until I get disconnected again. Using Win 98 and Netzero so I can't do a DUN connection. Any help would be appreciated!!!!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Jul 21, 2004 9:42 pm

This is from an earlier posting that I made that may help you:
Bob Hansen wrote:I just cut this out of a script that I had done a while ago. This is scheduled to run every 5 minutes and just pops up a status message. Intended to send multi emails when server was down.

Need to insert IP address to ping.

Output of PING goes to a file.
Find parses out the line with the ping results.
ReadLine gets the number of failures. If 0=OK, if 4=NG, if 1-3=Retry.
=============================
/Need to test email server and verify it is active.

Let>RP_WAIT=1
Let>CF_OVERWRITE=1
Let>RP_WINDOWMODE=0
Let>IP=127.000.000.001

Label>Start
Message>Running PING to Email Server now....
Run Program>command.com /c ping %IP% > c:\temp\tstmail1.txt

Message>Checking Results of Email Server status now....
Run Program>command.com /c find /c "timed out" c:\temp\tstmail1.txt >c:\temp\tstmail2.txt
ReadLn>c:\temp\tstmail2.txt,2,countline
Position>:,%countline%,30,start
Add>Start,30
MidStr>%countline%,%start%,2,count

Label>Test1
//Note, need different email account to send these messages if this email server is down.
If>%count%=4,NoMail,Test2

Label>Test2
If>%count%=0,Good,Start

Label>Good
Message>Email server is OK
//If good send OK mail, once every six hours
Goto>End

Label>NoMail
Message>Email server is DOWN
//If no good, send warning emails to tech support and group

Label>End
Comments for Run Program>commands:
WIN9X = use command.com
WINNT/XP/2K = use com

If doing Cut/Paste from forum be sure to remove any Trailing Space Characters.
This is just a sample to get you started. You could modify this to run your ISP connection vs. NoMail acrivities. Basically doing the same thing, checking for a valid connection and responding based on results.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

zodemere
Newbie
Posts: 8
Joined: Wed Jul 21, 2004 9:06 pm

thanks bob

Post by zodemere » Thu Jul 22, 2004 12:02 am

Thanks Bob, i appreciate your response but I'm a major newbie to this stuff so I still don't know what I'm doing??? So if i was to use that script and then have it say if there's no mail sever then run my macro to connect to the net??? sorry if i'm such a noob but thanks very much for the info!!!!

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Jul 22, 2004 1:40 am

Let me see if I can explain this for you:
Need to insert IP address to ping.

Output of PING goes to a file.
Find parses out the line with the ping results.
ReadLine gets the number of failures. If 0=OK, if 4=NG, if 1-3=Retry.
This was an explanation of what will happen. We will be using the DOS command FIND to get information from the DOS command PING, and looking at the number of failures. If no failures, then we are connected. If we get 4 failures we are not connected. If we get 1-3 failures, we are not sure so will try again.
/Need to test Internet connection and verify it is active.

Let>RP_WAIT=1
Let>CF_OVERWRITE=1
Let>RP_WINDOWMODE=0
Let>IP=127.000.000.001
This sets some variable for the script to work. RP_WAIT will pause the script commands until the Run Program has been completed. CF_OVERWRITE allows files to overwritten. WINDOWMODE has the DOS programs running in hidden windows. You must replace "127.000.000.001" with the correct IP address that you want to monitor. The value in here will be a variable that is used in later parts of the script.
Label>Start
Message>Running PING to Internet Server address now....
Run Program>command.com /c ping %IP% > c:\temp\tstmail1.txt
This runs the PING program and reirects the output to a text file, tstmail1.txt. You can go to a DOS prompt and run the command yourself to see the normal results. Try PING 127.000.000.001.
Message>Checking Results of Internet Server status now....
Run Program>command.com /c find /c "timed out" c:\temp\tstmail1.txt >c:\temp\tstmail2.txt
This uses FIND to look inside the text file tstmail1.txt and count the lines that have "timed out". (Those lines indicate a PING failure). the results of FIND are redirected to another textfile, "tstmail2.txt"
ReadLn>c:\temp\tstmail2.txt,2,countline
Position>:,%countline%,30,start
Add>Start,30
MidStr>%countline%,%start%,2,count
This section reads the second line of the tstmail2.txt file, looks for a semicolon as a reference point. MidString looks at the 2 characters 3o places beyond the semicolon and places the value in the variable "count"
Label>Test1
If>%count%=4,NoConnection,Test2

Label>Test2
If>%count%=0,Good
Message>Not sure of connection. Trying again in 3 seconds
Wait>3
Goto>Start

Label>Good
Message>Connection is OK
Goto>End

Label>NoConnection
Message>Internet connection is BROKEN
//If no good, send warning emails to tech support and group
//Insert whatever commands you need to make your connection.
//and test for connection again.
Goto>Start

Label>End
This section looks at the variable "count" and loops in the script based on value of "count"
Comments for Run Program>commands:
WIN9X = use command.com
WINNT/XP/2K = use com
The Run Program needs to use a different "command" value depending on its operating system.

If doing Cut/Paste from forum be sure to remove any Trailing Space Characters. Be sure to check the Help section for syntax and script samples for each command.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

zodemere
Newbie
Posts: 8
Joined: Wed Jul 21, 2004 9:06 pm

thanks again for explaining the script

Post by zodemere » Thu Jul 22, 2004 1:58 am

thanks again for explaining the script but i'm such a noob.....ok, so this script will allow me to detect whether or not i have a internet connection, but how do i use it to say if no internet then run this macro that will reconnect me????


my apologies again :)

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Jul 22, 2004 4:13 am

If you are disconnected, then you will probably have to do some troubleshooting to reestablish the connection. If you cannot PING, then none of your programs will be able to connect either.

To start diagnosis of problem, you can start PINGing TRACERTing starting with 127.0.0.1, then to your own internal IP, then to your closest router if on a network, then on then to other machines on your internal network, then to your gateway IP, then to your DNS1 and DNS2 servers. Depending where the PING stops will help you narrow in to where the problem is coming from.

You may get some advice here, but this forum is not the place to troubleshoot your Internet connections. You could modify the sample script to jump to the other IP addresses as noted above in the diagnostic, but you will still have to correct the problem before getting any other programs to connect.

Here is a sample batch file that I created years ago to perform the steps above. You will have to change the IP numbers to suit your particular environment. Warning....this has not been reviewed in years, and I am sure that I made modifications to it for improvement. Again, just a skeleton to give you some ideas to get started.

Example of how to use: If the Macro Scheduler script shows that you are disconnected you could have the script run this batch file. Or you could modify the Macro Scheduler to perform the steps in tha batch file directly in the script. Batch file "testinet.bat" contents:
@echo off
:: Most of the values can be obtained from running winipcfg with more info selected
:: Be sure to select the correct adaptor, there may be multiple listings.
:: DNS Servers will be at the top
:: IP address and gateway can be located in the lower section.
:: internal test will always be to 127.0.0.1
echo .
echo Next test is internal test of this machine
pause
ping 127.0.0.1
echo .
echo Next test is to this machine's IP address
pause
ping 192.168.12.12
echo .
echo Next test is to permanent Snap Drive on this internal network
pause
ping 192.168.12.79
echo .
echo Next test is to the Wireless Access port for the network
pause
ping 192.168.12.103
echo .
echo Next test is to the Workstation on Wireless Access network.
pause
ping 192.168.12.121
echo .
echo Next test is to the Firewall/Router for this network
pause
ping 192.168.12.50
echo .
echo Next test is to the Gateway for the Cable Modem (Dynamic)
pause
ping 66.31.92.1
echo .
echo Next test is to the first DNS address for this Cable Modem
pause
ping 123.89.52.188
echo .
echo Next test is to the second DNS address for this Cable Modem
pause
ping 76.152.41.154
echo .
echo Next test is to the IP for this Cable Modem (dynamic)
pause
ping 25.118.230.82
echo .
echo Next test is to a test site (22.64.239.7) provided by ISP tech on 5/5/03.
pause
:: Rem out next four lines if no third DNS
:: echo Next test is to the third DNS address for this machine
:: pause
:: ping 27.118.4.69
:: echo .
echo Next test is to the IP address of http://www.boston.com
pause
ping 66.150.192.100
echo .
echo Next test is to the URL name of http://www.boston.com
pause
ping boston.com
echo .
pause.
cls
@echo If there have been no problems to this point then press CTL-C to stop.
@echo .
@echo OR
@echo .
@echo If still having problems, then try for more details using tracert
pause
:: the following lines are using the DNS and boston.com addresses
:: DNS1
tracert 123.89.52.1889
:: DNS2
tracert 76.152.41.154
:: boston.com
tracert 66.150.192.100
tracerte boston.com
echo .
echo Next test is to a test site (22.64.239.7) provided by ISP tech on 5/5/03.
pause
tracerte 22.64.239.7
echo Tests are completed
pause
I actually have a version of this on some of my clients' main servers with variables for the local IP of the workstation. This way any user at a work station that loses connection can run this and send results to me for corrections/repair.

But again, this does not reestablish a connection, it only confirms that a connection is alive or not. Still need to troubleshoot, diagnose, and repair.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

zodemere
Newbie
Posts: 8
Joined: Wed Jul 21, 2004 9:06 pm

thanks again bob

Post by zodemere » Thu Jul 22, 2004 6:20 am

You mentioned something about trouble shooting my internet connection...ok here's the deal, this is how much of a newbie i am. I use Netzero to connect to the internet and they don't allow a DUN connection and I have to use their software (otherwise i could just use a auto dialer and forget macro scheduling). In my opinion they must be randomly disconnecting me because using any other ISP i can stay on for days at a time with no disconnection where as with Netzero i get disconnected at least a half dozen times per day. I would use another ISP but for some reason Netzero is the only ISP that gives me a true 53k connection speed and plus they're cheap. So I just need to figure out how to schedule a macro that will run my NZ software and re-run the same macro eveytime i get disconnected for general day to day use and if I want to download files while away on vaction. So my question is....is there an easier way than this previous script and could u or anyone give me some suggestions that a newbie like me could understand cuz I gotz a macro recorded that will run the software i just need to know how to get it to run when my connection drops.

Lumumba

Post by Lumumba » Thu Jul 22, 2004 7:23 am

As a newbi I wouldn't try to reinvent the wheel (on the other hand there's nothing to say against it - if you want to start scripting :wink: )

There several (hundreds?!) of tiny tools available to keep a connection alive (or to reconnect if forcefully disconneted).

Only one of it: Stay Live 2000 [more ...]

zodemere
Newbie
Posts: 8
Joined: Wed Jul 21, 2004 9:06 pm

Lumumba

Post by zodemere » Thu Jul 22, 2004 4:37 pm

Lumumba, thanks for the input and any other ideas on programs that will be able to detect when my internet connection is dropped and be able to reconnect me using the Netzero software would be great!!!

However this Stay Live 2000 and some other that I HAVE tried (stay connected, keep connected, always alive, ect) don't keep you online with Netzero. I think the reason being is that Netzero does a pattern check and after so much time can tell that the pattern is repeating thus not a real body in front of the computer so click, they disco you. Which wouldn't be a big deal if at least one of the proggies would be able to reconnect you using the Netzero software because Netzero does NOT allow a DUN connection. But all the programs i've tried so far which is quite extensive have a problem with running AOL, Netzero, and Juno software and are mostly setup for simple DUN connections.

So anyways this brings me to my next point which is even if i could find a good program that would auto reconnect my Netzero i still wouild like to have a macro that could do a host of things. Say each day reboot, cuz I'm using crap Win 98 and a reboot every few days is a must, then run my macro to see if i'm connected and if not then use Netzero software to connect me. Then download windows update, emails, and other files I'd want while I was away on vacation. So you see if i could just get a Macro or Script that could simply detect internet disco's and be able to reconnect me then I'd be set. Do you all know what I mean Vern???

thanks again everyone for the looks and responses!!!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts