1.

Solve : Basic batch file question?

Answer»

I'd like to time responses from my various mail servers. (I need to demonstrate performance problems to ISP.) Pseudocode would be

get time
telnet domain1 25
quit
get time
display interval
repeat for domain2

Apparently, telnet is waiting on keyboard.

1. How do I redirect input for telnet to batch FILE instead of keyboard?

2. Does anyone know where sample date arithmetic code to show interval exists?

(I've been looking and not finding answers to both questions.)

Thanks in advance for the help,

PKFirst create a file that has the same commands that you would use in your telnet session. For example, create a file called telnet.txt with:
Code: [Select]helo
test.com
quit
Then create a batch file similar to:
Code: [Select]@echo off
for %%a in (domain1.com domain2.com) do (
echo Initializing connection to %%a at %time%
telnet %%a 25 <telnet.txt >NUL
echo Connection to %%a established at %time%
echo.
)
echo Finished.
Replace your domains with "domain1.com" and "domain2.com" above.Gary, thanks so much. I learned a ton with that attempt.

I cannot get telnet to process in same order as when I do commands manually. When I do it via keyboard, telnets waits for initialization of smtp server, then reads keyboard input.

When I do via batch file, telnet seems to crater before it even TRIES to initialize connection on port 25.

Thanks again,

PKAn alternative using python smtp module.
Code: [Select]import smtplib,time
starttime = time.time()
print "Start time : %s " % (starttime)
smtp = smtplib.SMTP("mailserver")
try:
smtp.ehlo("mailserver")
EXCEPT smtplib.SMTPHeloError:
print "HELO error from Smtpserver"
else:
stoptime = time.time()
print "Stop time: %s" %(stoptime)
print "Time difference: %s seconds" %((stoptime - starttime))
GhostDog and Gary... thanks for the help.

The python solution was over my head...

I was able to demonstrate the problem to my ISP in a way that they see the problem. (We'll see if they can fix it?)

Thanks again for the help,

PK



Discussion

No Comment Found