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 "------< Session begin at "
strcat LogLine $TIME
strcat LogLine " >------"
fputs 0 LogLine
if fopen 1 LstFile READ TEXT
while not feof 1
fgets 1 StrLine
if strnicmp StrLine "[Begin]" 7
fgets 1 S0 ; EntryName
fgets 1 S2 ; ID
fgets 1 S3 ; password
S9 = "" ; Connection Message
I0 = 0 ; Logon or not
execute "logon" SHARED
if I0
strcpy LogLine " + "
strcat LogLine S9
strcat LogLine " --- Logon "
strcat LogLine S0
fputs 0 LogLine
PAUSE 1
transmit "set def [poll.in]^M"
transmit "kermit^M"
waitfor "kermit-32"
pause 1
Cnt = 0
Looping = 1
while Looping
fgets 1 StrLine
if strnicmp StrLine "[Poll]" 6
Looping = 0
else
strlen StrLine Len
if Len > 0
if isfile StrLine
getfilename FileName StrLine
if strfind FileName "$"
transmit "receive "
transmit FileName
transmit "^M"
else
transmit "receive^M"
endif
Pause 1
sendfile kermit StrLine
While $XFerStatus && $Carrier
yield
EndWhile
transmit "^M"
Cnt++
SndList[Cnt] = StrLine
HasSent[Cnt] = 0
endif
endif
endif
endwhile
transmit "quit^M"
pause 2
strcpy CapFile LogPath
strcat CapFile "\filelist.cap"
set capture file "filelist.cap"
capture on
transmit "dire^M"
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 "$"
strreplace FileName "_" ""
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 " --- "
else
strcpy LogLine " *** "
endif
getfilename FileName SndList[Pos]
strcat LogLine FileName
if HasSent[Pos]
strcat LogLine " sent."
copyfile SndList[Pos] BkpPath
delfile SndList[Pos]
else
strcat LogLine " not sent!!!"
endif
fputs 0 LogLine
endfor
transmit "set def [poll.out]^M"
strcpy CapFile LogPath
strcat CapFile "\filelist.cap"
set capture file "filelist.cap"
capture on
transmit "dire^M"
pause 2
capture off
transmit "kermit^M"
waitfor "kermit-32"
pause 1
Looping = 1
while Looping
fgets 1 StrLine
if strnicmp StrLine "[End]" 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 = "send "
strcat CmdLine FileName
transmit CmdLine
transmit "^M"
pause 1
set dnldpath FilePath
getfile kermit
While $XFerStatus && $Carrier
yield
EndWhile
transmit "^M"
endif
strcpy LogLine " --- "
strcat LogLine FileName
strcat LogLine " polled."
fputs 0 LogLine
else
strcpy LogLine " *** "
strcat LogLine FileName
strcat LogLine " not existed!!!"
fputs 0 LogLine
endif
endif
endif
endwhile
delfile CapFile
transmit "quit^M"
transmit "ringbell^M"
pause 1
transmit "log^M"
While $CARRIER
EndWhile
pause 3
else
if nullstr S9
strcpy LogLine "*** ERROR *** --- Can't connect with "
else
strcpy LogLine " + "
strcat LogLine S9
strcat LogLine "...... Can't logon "
endif
strcat LogLine S0
fputs 0 LogLine
endif
endif
endwhile
fclose 1
else
fputs 0 "*** ERROR *** --- Can't open List File!!!"
endif
strcpy StrLine "-------< Session end at "
strcat StrLine $TIME
strcat StrLine " >-------"
fputs 0 StrLine
fclose 0
else
usermsg "Can't open Log File %s!!!" 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 "%s: %s" S0
S9 = $CNCTMSG
transmit "^M"
transmit "^M"
transmit "^M"
pause 2
transmit "^M"
while Looping
Cnt++
waitfor "Username:" 10
if Cnt > 10
Looping = 0
elseif SUCCESS
Looping = 0
endif
EndWhile
transmit "^M"
transmit "^M"
Looping = 1
Cnt = 1
While Looping
Cnt++
waitfor "Username:" 10
if Cnt > 10
Looping = 0
elseif SUCCESS
Looping = 0
endif
EndWhile
transmit S2 ; User ID
transmit "^M"
waitfor "Password:"
transmit S3 ; Password
transmit "^M"
if SUCCESS
I0 = 1
else
transmit "log^M"
pause 2
disconnect
endif
else
statmsg "%s: %s" S0 $CNCTMSG
pause 2
endif
endproc
----------------End of Logon.was ---------------
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 "------< Session begin at "
strcat LogLine $TIME
strcat LogLine " >------"
fputs 0 LogLine
if fopen 1 LstFile READ TEXT
while not feof 1
fgets 1 StrLine
if strnicmp StrLine "[Begin]" 7
fgets 1 S0 ; EntryName
fgets 1 S2 ; ID
fgets 1 S3 ; password
S9 = "" ; Connection Message
I0 = 0 ; Logon or not
execute "logon" SHARED
if I0
strcpy LogLine " + "
strcat LogLine S9
strcat LogLine " --- Logon "
strcat LogLine S0
fputs 0 LogLine
PAUSE 1
transmit "set def [poll.in]^M"
transmit "kermit^M"
waitfor "kermit-32"
pause 1
Cnt = 0
Looping = 1
while Looping
fgets 1 StrLine
if strnicmp StrLine "[Poll]" 6
Looping = 0
else
strlen StrLine Len
if Len > 0
if isfile StrLine
getfilename FileName StrLine
if strfind FileName "$"
transmit "receive "
transmit FileName
transmit "^M"
else
transmit "receive^M"
endif
Pause 1
sendfile kermit StrLine
While $XFerStatus && $Carrier
yield
EndWhile
transmit "^M"
Cnt++
SndList[Cnt] = StrLine
HasSent[Cnt] = 0
endif
endif
endif
endwhile
transmit "quit^M"
pause 2
strcpy CapFile LogPath
strcat CapFile "\filelist.cap"
set capture file "filelist.cap"
capture on
transmit "dire^M"
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 "$"
strreplace FileName "_" ""
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 " --- "
else
strcpy LogLine " *** "
endif
getfilename FileName SndList[Pos]
strcat LogLine FileName
if HasSent[Pos]
strcat LogLine " sent."
copyfile SndList[Pos] BkpPath
delfile SndList[Pos]
else
strcat LogLine " not sent!!!"
endif
fputs 0 LogLine
endfor
transmit "set def [poll.out]^M"
strcpy CapFile LogPath
strcat CapFile "\filelist.cap"
set capture file "filelist.cap"
capture on
transmit "dire^M"
pause 2
capture off
transmit "kermit^M"
waitfor "kermit-32"
pause 1
Looping = 1
while Looping
fgets 1 StrLine
if strnicmp StrLine "[End]" 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 = "send "
strcat CmdLine FileName
transmit CmdLine
transmit "^M"
pause 1
set dnldpath FilePath
getfile kermit
While $XFerStatus && $Carrier
yield
EndWhile
transmit "^M"
endif
strcpy LogLine " --- "
strcat LogLine FileName
strcat LogLine " polled."
fputs 0 LogLine
else
strcpy LogLine " *** "
strcat LogLine FileName
strcat LogLine " not existed!!!"
fputs 0 LogLine
endif
endif
endif
endwhile
delfile CapFile
transmit "quit^M"
transmit "ringbell^M"
pause 1
transmit "log^M"
While $CARRIER
EndWhile
pause 3
else
if nullstr S9
strcpy LogLine "*** ERROR *** --- Can't connect with "
else
strcpy LogLine " + "
strcat LogLine S9
strcat LogLine "...... Can't logon "
endif
strcat LogLine S0
fputs 0 LogLine
endif
endif
endwhile
fclose 1
else
fputs 0 "*** ERROR *** --- Can't open List File!!!"
endif
strcpy StrLine "-------< Session end at "
strcat StrLine $TIME
strcat StrLine " >-------"
fputs 0 StrLine
fclose 0
else
usermsg "Can't open Log File %s!!!" 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 "%s: %s" S0
S9 = $CNCTMSG
transmit "^M"
transmit "^M"
transmit "^M"
pause 2
transmit "^M"
while Looping
Cnt++
waitfor "Username:" 10
if Cnt > 10
Looping = 0
elseif SUCCESS
Looping = 0
endif
EndWhile
transmit "^M"
transmit "^M"
Looping = 1
Cnt = 1
While Looping
Cnt++
waitfor "Username:" 10
if Cnt > 10
Looping = 0
elseif SUCCESS
Looping = 0
endif
EndWhile
transmit S2 ; User ID
transmit "^M"
waitfor "Password:"
transmit S3 ; Password
transmit "^M"
if SUCCESS
I0 = 1
else
transmit "log^M"
pause 2
disconnect
endif
else
statmsg "%s: %s" S0 $CNCTMSG
pause 2
endif
endproc
----------------End of Logon.was ---------------