Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error message "TELNET Winsock Error - Connect Failed - Error No.(0)

Status
Not open for further replies.

chiuhong

Technical User
Jun 28, 2000
26
HK
Does anyone help on my scripts below?
I encountered problem as if connect TELNET S0 is failed(some reasons with TCP failed throught), Error message "TELNET Winsock Error - Connect Failed - Error No.(0), the scripts will holded and wait for long time before next connection, even never go next again, does anyone have any idea how to detect see if TCP/IP failed, it will retry for 2 times and if still failed then go next.I have no idea on my scripts how to handle that!




---------------Start of main.was -------------------
proc main
integer Pos, Len, Cnt, Existed, Looping
integer HasSent[200]
string SndList[200]
string WasPath = "C:\Aspect"
string LogPath = "C:\Aspect\Log"
String BkpPath = "\\XXXXXX\Filmfile\Poll_Out\Backup"
string LogFile, LstFile, CapFile, FileName, FilePath
string StrLine, LogLine, CmdLine, LstLine
string MMDD, DD
string SemFile, StnNo
strcpy StnNo S0
strcpy SemFile LogPath
Strcat SemFile "\Status."
Strcat SemFile S0
substr MMDD $DATE 0 2
substr DD $DATE 3 2
strcat MMDD DD
strcpy LogFile LogPath
Strcat LogFile "\c"
strcat LogFile MMDD
strcat LogFile S0
strcat LogFile ".log"
strcpy LstFile WasPath
strcat LstFile "\filelist."
Strcat LstFile S0
set capture path LogPath
set aspect path WasPath
fopen 0 SemFile READWRITE TEXT
fputs 0 "Working..."
fclose 0
if fopen 0 LogFile APPEND TEXT
fputs 0 "================================================================================"
strcpy LogLine &quot;------< Session begin at &quot;
strcat LogLine $TIME
strcat LogLine &quot; >------&quot;
fputs 0 LogLine
if fopen 1 LstFile READ TEXT
while not feof 1
fgets 1 StrLine
if strnicmp StrLine &quot;[Begin]&quot; 7
fgets 1 S0 ; EntryName
fgets 1 S2 ; ID
fgets 1 S3 ; password
S9 = &quot;&quot; ; Connection Message
I0 = 0 ; Logon or not
execute &quot;logon&quot; SHARED
if I0
strcpy LogLine &quot; + &quot;
strcat LogLine S9
strcat LogLine &quot; --- Logon &quot;
strcat LogLine S0
fputs 0 LogLine
PAUSE 1
transmit &quot;set def [poll.in]^M&quot;
transmit &quot;kermit^M&quot;
waitfor &quot;kermit-32&quot;
pause 1
Cnt = 0
Looping = 1
while Looping
fgets 1 StrLine
if strnicmp StrLine &quot;[Poll]&quot; 6
Looping = 0
else
strlen StrLine Len
if Len > 0
if isfile StrLine
getfilename FileName StrLine
if strfind FileName &quot;$&quot;
transmit &quot;receive &quot;
transmit FileName
transmit &quot;^M&quot;
else
transmit &quot;receive^M&quot;
endif
Pause 1
sendfile kermit StrLine
While $XFerStatus && $Carrier
yield
EndWhile
transmit &quot;^M&quot;
Cnt++
SndList[Cnt] = StrLine
HasSent[Cnt] = 0
endif
endif
endif
endwhile
transmit &quot;quit^M&quot;
pause 2
strcpy CapFile LogPath
strcat CapFile &quot;\filelist.cap&quot;
set capture file &quot;filelist.cap&quot;
capture on
transmit &quot;dire^M&quot;
pause 2
capture off
if fopen 2 CapFile READ TEXT
while not feof 2
fgets 2 StrLine
for Pos = 1 upto Cnt
if !HasSent[Pos]
getfilename FileName SndList[Pos]
strupr FileName
strupr StrLine
if not strfind FileName &quot;$&quot;
strreplace FileName &quot;_&quot; &quot;&quot;
endif
if strfind StrLine FileName
HasSent[Pos] = 1
endif
endif
endfor
endwhile
fclose 2
delfile CapFile
endif
for Pos = 1 upto Cnt
if HasSent[Pos]
strcpy LogLine &quot; --- &quot;
else
strcpy LogLine &quot; *** &quot;
endif
getfilename FileName SndList[Pos]
strcat LogLine FileName
if HasSent[Pos]
strcat LogLine &quot; sent.&quot;
copyfile SndList[Pos] BkpPath
delfile SndList[Pos]
else
strcat LogLine &quot; not sent!!!&quot;
endif
fputs 0 LogLine
endfor
transmit &quot;set def [poll.out]^M&quot;
strcpy CapFile LogPath
strcat CapFile &quot;\filelist.cap&quot;
set capture file &quot;filelist.cap&quot;
capture on
transmit &quot;dire^M&quot;
pause 2
capture off
transmit &quot;kermit^M&quot;
waitfor &quot;kermit-32&quot;
pause 1
Looping = 1
while Looping
fgets 1 StrLine
if strnicmp StrLine &quot;[End]&quot; 5
Looping = 0
else
strlen StrLine Len
if Len > 0
getfilename FileName StrLine
getpathname FilePath StrLine
if fopen 2 CapFile READ TEXT
while not feof 2
fgets 2 LstLine
strupr FileName
strupr LstLine
if strfind LstLine FileName
Existed = 1
exitwhile
else
Existed = 0
endif
endwhile
fclose 2
endif
if Existed
if not isfile StrLine
CmdLine = &quot;send &quot;
strcat CmdLine FileName
transmit CmdLine
transmit &quot;^M&quot;
pause 1
set dnldpath FilePath
getfile kermit
While $XFerStatus && $Carrier
yield
EndWhile
transmit &quot;^M&quot;
endif
strcpy LogLine &quot; --- &quot;
strcat LogLine FileName
strcat LogLine &quot; polled.&quot;
fputs 0 LogLine
else
strcpy LogLine &quot; *** &quot;
strcat LogLine FileName
strcat LogLine &quot; not existed!!!&quot;
fputs 0 LogLine
endif
endif
endif
endwhile
delfile CapFile
transmit &quot;quit^M&quot;
transmit &quot;ringbell^M&quot;
pause 1
transmit &quot;log^M&quot;
While $CARRIER
EndWhile
pause 3
else
if nullstr S9
strcpy LogLine &quot;*** ERROR *** --- Can't connect with &quot;
else
strcpy LogLine &quot; + &quot;
strcat LogLine S9
strcat LogLine &quot;...... Can't logon &quot;
endif
strcat LogLine S0
fputs 0 LogLine
endif
endif
endwhile
fclose 1
else
fputs 0 &quot;*** ERROR *** --- Can't open List File!!!&quot;
endif
strcpy StrLine &quot;-------< Session end at &quot;
strcat StrLine $TIME
strcat StrLine &quot; >-------&quot;
fputs 0 StrLine
fclose 0
else
usermsg &quot;Can't open Log File %s!!!&quot; LogFile
endif
delfile SemFile
pwexit
endproc
---------------End of main.was -------------------





----------------Start of Logon.was ---------------


proc main
integer Looping = 1, Cnt = 1
set dial retries 1
dial TELNET S0
While $DIALING ; wait for dial-up
yield
EndWhile
if $CARRIER
statmsg &quot;%s: %s&quot; S0
S9 = $CNCTMSG
transmit &quot;^M&quot;
transmit &quot;^M&quot;
transmit &quot;^M&quot;
pause 2
transmit &quot;^M&quot;
while Looping
Cnt++
waitfor &quot;Username:&quot; 10
if Cnt > 10
Looping = 0
elseif SUCCESS
Looping = 0
endif
EndWhile
transmit &quot;^M&quot;
transmit &quot;^M&quot;
Looping = 1
Cnt = 1
While Looping
Cnt++
waitfor &quot;Username:&quot; 10
if Cnt > 10
Looping = 0
elseif SUCCESS
Looping = 0
endif
EndWhile
transmit S2 ; User ID
transmit &quot;^M&quot;
waitfor &quot;Password:&quot;
transmit S3 ; Password
transmit &quot;^M&quot;
if SUCCESS
I0 = 1
else
transmit &quot;log^M&quot;
pause 2
disconnect
endif
else
statmsg &quot;%s: %s&quot; S0 $CNCTMSG
pause 2
endif
endproc
----------------End of Logon.was ---------------
 
Couple ideas of what could be wrong.
1.Check the address you are trying to telnet.
Does your script run properly after a manual connection?

2. Procomm cannot connect to address 1, disconnect, then connect to address 2. Procomm cannot detect a disconnect in telnet.




&quot;I will not be pushed, filed, stamped, indexed, briefed, debriefed or numbered.&quot;
No. 6
 
actually, I have more hundred stores Servers, first, I had VB scripts retrieve information needed(Stores ip, username and Password) from SQL DB result as a text file! the scripts above read & looping from the text file! since we are ADSL line connecting between stores and quite not stable line. sometime never go through. The above scripts worked well with dialup modem(since modem be able to detect if phone line busy)! however, we did switch to ADSL from Modem now.
As your suggestion, there are no way to do with Telnet if Problems with ADSL LINE? no detect function?

Thanks
 
If all you need is to know if a telnet connection was made or not, you can check the value of $CARRIER after attempting the connection, which it appears you are doing already. When these problems occur, is your Internet connection down by chance so that you cannot make any telnet connections at all?


aspect@aspectscripting.com
 
Yes, our Internet connection down by chance(more hundred of stores Internet connection )! as my scripts above will keep waiting for long time if Internet connection down by chance, if any functions will make it TIMEOUT and go next during Internet connection down.
 
I am not aware of any way to tell if an Internet connection is available other than trying to make the connection via your script.

If you want to see if a connection could not be made due to the error message you mentioned, you can check the contents of the status line by querynig the $STATUSMSG system variable.


aspect@aspectscripting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top