if intReturn <> 0 then If Err.Number <> 0 Then strLog = "Err.Number : " & Err.Number & vbCrLf strLog = strLog & "Err.Description : " & Err.Description & vbCrLf End If Else
strLog = "########### " & currDate & " 업데이트 ############" & vbCrLf If objFSO.FileExists(srcFolder & "\" & ConvertDate & ".arj") Then strLog = strLog & ConvertDate & ".arj 파일을 가져왔습니다." & vbCrLf objShell.Run("arj32 x -y " & ConvertDate ) strLog = strLog & ConvertDate & ".arj 압축 파일을 풀었습니다." & vbCrLf Else strLog = strLog & "업데이트가 없습니다. " & vbCrLf End If End If
Function ConvertDate8(Byval currDate) If IsDate(currDate) Then ConvertDate8 = Replace(FormatDateTime(currDate, 2), "-", "") Else ConvertDate8 = "" End If End Function
원격지에서 압축파일을 가져와 압축을 푸는 스크립트
Option Explicit
Dim currDate, ConvertDate
Dim objFSO, objShell, srcFolder
Dim intReturn, ftpLog, strLog
currDate = DateAdd("d", 0 , Date)
ConvertDate = ConvertDate8(currDate)
srcFolder = "C:\xodim\UpdateSrc"
Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objShell = WScript.CreateObject("WScript.Shell")
ftpLog = "open 111.111.111.111" & vbCRLF
ftpLog = ftpLog & "ftp 계정" & vbCRLF
ftpLog = ftpLog & "ftp 패스워드" & vbCRLF
ftpLog = ftpLog & "binary" & vbCRLF
ftpLog = ftpLog & "prompt" & vbCRLF
ftpLog = ftpLog & "cd /Update" & vbCRLF
ftpLog = ftpLog & "get " & ConvertDate & ".arj" & vbCRLF
ftpLog = ftpLog & "bye " & vbCrLf
Set objLog = objFSO.OpenTextFile(srcFolder & "\" & "ftp.txt", 2, True)
objlog.Write ftpLog
objlog.Close
intReturn = objShell.Run("ftp -s:ftp.txt", 0, True)
if intReturn <> 0 then
If Err.Number <> 0 Then
strLog = "Err.Number : " & Err.Number & vbCrLf
strLog = strLog & "Err.Description : " & Err.Description & vbCrLf
End If
Else
If objFSO.FileExists(srcFolder & "\" & ConvertDate & ".arj") Then
strLog = strLog & ConvertDate & ".arj 파일을 가져왔습니다." & vbCrLf
objShell.Run("arj32 x -y " & ConvertDate )
strLog = strLog & ConvertDate & ".arj 압축 파일을 풀었습니다." & vbCrLf
Else
strLog = strLog & "업데이트가 없습니다. " & vbCrLf
End If
End If
Function ConvertDate8(Byval currDate)
If IsDate(currDate) Then
ConvertDate8 = Replace(FormatDateTime(currDate, 2), "-", "")
Else
ConvertDate8 = ""
End If
End Function
Dim objLog, strScriptFullName
strScriptFullName = WScript.ScriptFullName
Set objLog = objFSO.OpenTextFile(strFolder & "\log\" & Replace(FormatDateTime(Date, 2), "-", "") & ".log", 2, True)
objLog.Write strLog
objLog.Close
'개발이야기' 카테고리의 다른 글