|
[ Machiavelli... @ 11.10.2012. 20:37 ] @
[ Machiavelli... @ 12.10.2012. 00:55 ] @
Evo do sad da uzmem input od usera
Option Explicit
Dim Message, result
Dim Title, Text1, Text2
' Define dialog box variables.
Message = "Please enter IP Address. Your Log files are going to be in 'c:/ip_address-date' folder"
Title = "RF Scanner Log downloader"
Text1 = "User input canceled"
Text2 = vbCrLf
' Ready to use the InputBox function
' InputBox(prompt, title, default, xpos, ypos)
' prompt: The text shown in the dialog box
' title: The title of the dialog box
' default: Default value shown in the text box
' xpos/ypos: Upper left position of the dialog box
' If a parameter is omitted, VBScript uses a default value.
result = InputBox(Message, Title, "Something like 10.67.184.15", 100, 100)
' Evaluate the user input.
If result = "" Then ' Canceled by the user
WScript.Echo Text1
Else
WScript.Echo Text2 & result
End If
'*** End
E sad umesto ispisa sta je user uneo hocu da mi skine fileove
http://ip_koji_sam_ukucao/netlog0.cap
http://ip_koji_sam_ukucao/netlog1.cap
http://ip_koji_sam_ukucao/scrncap.bmp
http://ip_koji_sam_ukucao/TELog.txt
http://ip_koji_sam_ukucao/deviceinfo.txt
http://ip_koji_sam_ukucao/processsummary.txt
http://ip_koji_sam_ukucao/TelnetLog.txt
http://ip_koji_sam_ukucao/TelnetLog.txt.1
http://ip_koji_sam_ukucao/TelnetLog.txt.2
http://ip_koji_sam_ukucao/TelnetLog.txt.3
http://ip_koji_sam_ukucao/TelnetLog.txt.4
znaci ovaj druge "else" mi sledi.. Polako napredujem, skidam sa neta primere, prepravljam...
[ Burgos @ 12.10.2012. 01:10 ] @
Za download:
Code:
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
Public Function DownloadFile(sSourceUrl As String, _
sLocalFile As String) As Boolean
//'Download the file. BINDF_GETNEWESTVERSION forces
//'the API to download from the specified source.
//'Passing 0& as dwReserved causes the locally-cached
//'copy to be downloaded, if available. If the API
//'returns ERROR_SUCCESS (0), DownloadFile returns True.
DownloadFile = URLDownloadToFile(0&, _
sSourceUrl, _
sLocalFile, _
BINDF_GETNEWESTVERSION, _
0&) = ERROR_SUCCESS
End Function
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _ Alias "DeleteUrlCacheEntryA" _ (ByVal lpszUrlName As String) As Long
Dim Message, result
Dim Title, Text1, Text2
' Define dialog box variables.
Message = "Please enter IP Address. Your Log files are going to be in 'c:/ip_address-date' folder"
Title = "RF Scanner Log downloader"
Text1 = "User input canceled"
Text2 = vbCrLf
' Ready to use the InputBox function
' InputBox(prompt, title, default, xpos, ypos)
' prompt: The text shown in the dialog box
' title: The title of the dialog box
' default: Default value shown in the text box
' xpos/ypos: Upper left position of the dialog box
' If a parameter is omitted, VBScript uses a default value.
result = InputBox(Message, Title, "Something like 10.67.184.15", 100, 100)
' Evaluate the user input.
If result = "" Then ' Canceled by the user
WScript.Echo Text1
Else
WScript.Echo Text2 & result
' Da bi skinuo fajl, pozoveš ove dve funkcije
DeleteUrlCacheEntry("http://download.cdn.mozilla.ne...S/Firefox%20Setup%2016.0.1.exe") ' da ocistis kes
DownloadFile("http://download.cdn.mozilla.ne...S/Firefox%20Setup%2016.0.1.exe", _
"C:\Users\Burgos\Desktop\Firefox.exe")
End If
'*** End
Sabio mi je firefoxov url, pa stavi tu validnu lokaciju.
[ Machiavelli... @ 12.10.2012. 01:28 ] @
Pa nadjoh kako da skinem odredjeni file. Medjutim meni treba da se posle drugog else
1. Kreira folder, formata "datum_unos-usera" (ovo cu se snaci)
2. Zatim da skinem fileove
http://unos_usera/netlog0.cap
http://unos_usera/netlog1.cap
.....
Treba mi varijabla sto je uzer uneo (ip adresa) da kreira link za download
http://unos_usera/netlog1.cap
[ Machiavelli... @ 12.10.2012. 18:48 ] @
Evo dokle sam stigao . Echovao sam ono sto mi treba. E sad umesto prvoh echo treba mi da napravim folder, a umesto drugog echo da poskida te linkove koji su generisani...
Code:
Option Explicit
Dim Message, result
Dim Title, Text1, Text2, strDate
Dim d : d = Date()
Dim dateStr : dateStr = Year(d) & "-" & Right("00" & Month(d), 2) & "-" & Right("00" & Day(d), 2)
' Define dialog box variables.
Message = "Please enter IP Address. Your Log files are going to be in 'c:/ip_address-date' folder"
Title = "RF Scanner Log downloader"
Text1 = "User input canceled"
Text2 = vbCrLf
strDate = Date()
' Ready to use the InputBox function
' InputBox(prompt, title, default, xpos, ypos)
' prompt: The text shown in the dialog box
' title: The title of the dialog box
' default: Default value shown in the text box
' xpos/ypos: Upper left position of the dialog box
' If a parameter is omitted, VBScript uses a default value.
result = InputBox(Message, Title, "Something like 10.67.184.15", 100, 100)
' Evaluate the user input.
If result = "" Then ' Canceled by the user
WScript.Echo Text1
Else
WScript.Echo ""&result&"-"&datestr
WScript.Echo "http://"&result&"/netcap0.log"
End If
[ reiser @ 12.10.2012. 19:17 ] @
Unajmi nekog freelancera koji ce ti ovo otkucati za 30min u nekom jeziku :)
[ Burgos @ 12.10.2012. 22:38 ] @
Umesto prvog echoa
Code: MkDir ""&result&"-"&datestr
umesto drugog
Code: DeleteUrlCacheEntry "http://"&result&"/netcap0.log"
DownloadFile("http://"&result&"/netcap0.log", _
""&result&"-"&datestr&"/netcap0.log")
[ Machiavelli... @ 12.10.2012. 23:00 ] @
Probao sam vec sa ovim ali dobijam
'Variable is undefiend: 'MkDir'
[ Burgos @ 13.10.2012. 00:03 ] @
Izvini, moja greška.
Code: Set objFSO = CreateObject("Scripting.FileSystemObject")
'za svaki folder, pozovi ovu funkciju - onu iznad samo jedanput.
objFSO.CreateFolder ""&result&"-"&datestr
[ Machiavelli... @ 13.10.2012. 00:42 ] @
Nece ovo meni da radi, nesto ja ne radim kako treba.
Code: Option Explicit
Dim Message, result
Dim Title, Text1, Text2, strDate
Dim d : d = Date()
Dim dateStr : dateStr = Year(d) & "-" & Right("00" & Month(d), 2) & "-" & Right("00" & Day(d), 2)
' Define dialog box variables.
Message = "Please enter IP Address. Your Log files are going to be in 'c:/ip_address-date' folder"
Title = "RF Scanner Log downloader"
Text1 = "User input canceled"
Text2 = vbCrLf
strDate = Date()
' Ready to use the InputBox function
' InputBox(prompt, title, default, xpos, ypos)
' prompt: The text shown in the dialog box
' title: The title of the dialog box
' default: Default value shown in the text box
' xpos/ypos: Upper left position of the dialog box
' If a parameter is omitted, VBScript uses a default value.
result = InputBox(Message, Title, "Something like 10.67.184.15", 100, 100)
' Evaluate the user input.
If result = "" Then ' Canceled by the user
WScript.Echo Text1
Else
Set objFSO = CreateObject("Scripting.FileSystemObject")
'za svaki folder, pozovi ovu funkciju - onu iznad samo jedanput.
objFSO.CreateFolder ""&result&"-"&datestr
DeleteUrlCacheEntry "http://"&result&"/netcap0.log"
DownloadFile "http://"&result&"/netcap0.log", _
""&result&"-"&datestr&"/netcap0.log"
End If
Dobijam object undefined objFSO
[ rajco @ 13.10.2012. 00:47 ] @
Jesi li razmišljao da ovo uradiš preko PS-a? Bolje da učiš njega nego VB.
[ Machiavelli... @ 13.10.2012. 00:56 ] @
Pa moze i to... Ne uci mi se VB totalno (nitio mi je to posao :-). Vec sam uradio ovo za bash ali samo ja koristim, i ovo treba vise junior technician koji svi do jednog koriste Windows. Moguce da cu preko PowerShell onda, smara ovaj VB. Bash je zakon ovo sve je 10-ak linija coda.
[ ventura @ 13.10.2012. 13:15 ] @
Evo ti gotova aplikacija.
1. Korisnik unese IP adresu
2. Kreira se folder IP_DATUM
3. Downloaduju se svi fajlovi sa liste
4. Zipuje se ceo folder
Snimi ovo kao fajl sa ekstenzijom .vbs i ako si na Windows7 mašini onda moraš da ga pokreneš kao administrator "Run As Administrator", ili da ga pokreneš preko elevated command prompta komandom "wscript.exe imeskripta.vbs"
Code:
' Get input from the user (IP address)
Dim IP
IP = InputBox( "Enter target IP address:" )
' Establish a Folder name & Create a folder
' Folder Name IP_DATE
Dim myDateString
myDateString = Date()
myDateString = Replace(myDateString, "/", "-") 'Must get rid of / in date, otherwise folder creation will fail
Dim FolderName
FolderName = IP & "_" & myDateString
' Now create a folder
Dim oFSO
Set oFSO = CreateObject("Scripting.FileSystemObject")
oFSO.CreateFolder FolderName
' Download the files
HTTPDownload "http://" & IP & "/netlog0.cap", FolderName
HTTPDownload "http://" & IP & "/netlog1.cap", FolderName
HTTPDownload "http://" & IP & "/scrncap.bmp", FolderName
HTTPDownload "http://" & IP & "/TELog.txt", FolderName
HTTPDownload "http://" & IP & "/deviceinfo.txt", FolderName
HTTPDownload "http://" & IP & "/processsummary.txt", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt.1", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt.2", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt.3", FolderName
HTTPDownload "http://" & IP & "/TelnetLog.txt.4", FolderName
' Create archive from the newly created folder
CreateZip FolderName & ".zip", FolderName
' SUBROUTINES
Sub HTTPDownload( myURL, myPath )
' This Sub downloads the FILE specified in myURL to the path specified in myPath.
Dim i, objFile, objFSO, objHTTP, strFile, strMsg
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set objFSO = CreateObject( "Scripting.FileSystemObject" )
If objFSO.FolderExists( myPath ) Then
strFile = objFSO.BuildPath( myPath, Mid( myURL, InStrRev( myURL, "/" ) + 1 ) )
ElseIf objFSO.FolderExists( Left( myPath, InStrRev( myPath, "\" ) - 1 ) ) Then
strFile = myPath
Else
WScript.Echo "ERROR: Target folder not found."
Exit Sub
End If
Set objFile = objFSO.OpenTextFile( strFile, ForWriting, True )
Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
objHTTP.Open "GET", myURL, False
objHTTP.Send
For i = 1 To LenB( objHTTP.ResponseBody )
objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) )
Next
objFile.Close( )
End Sub
Sub NewZip(pathToZipFile)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Dim file
Set file = fso.CreateTextFile(pathToZipFile)
file.Write Chr(80) & Chr(75) & Chr(5) & Chr(6) & String(18, 0)
file.Close
Set fso = Nothing
Set file = Nothing
WScript.Sleep 500
End Sub
Sub CreateZip(pathToZipFile, dirToZip)
'WScript.Echo "Creating zip (" & pathToZipFile & ") from (" & dirToZip & ")"
Dim fso
Set fso= Wscript.CreateObject("Scripting.FileSystemObject")
pathToZipFile = fso.GetAbsolutePathName(pathToZipFile)
dirToZip = fso.GetAbsolutePathName(dirToZip)
If fso.FileExists(pathToZipFile) Then
'WScript.Echo "That zip file already exists - deleting it."
fso.DeleteFile pathToZipFile
End If
If Not fso.FolderExists(dirToZip) Then
'WScript.Echo "The directory to zip does not exist."
Exit Sub
End If
NewZip pathToZipFile
dim sa
set sa = CreateObject("Shell.Application")
Dim zip
Set zip = sa.NameSpace(pathToZipFile)
Dim d
Set d = sa.NameSpace(dirToZip)
' Look at http://msdn.microsoft.com/en-us/library/bb787866(VS.85).aspx
' for more information about the CopyHere function.
zip.CopyHere d.items, 4
Do Until d.Items.Count <= zip.Items.Count
Wscript.Sleep(200)
Loop
End Sub
[Ovu poruku je menjao ventura dana 13.10.2012. u 14:27 GMT+1]
[ Machiavelli... @ 13.10.2012. 15:38 ] @
Hvala, hvala, hvala Ventura!
Inace probah i PS ali nemaju privilegije da runn scripte na masinama tako da je morao VB.
Hvala jos jednom.
Ziveli!
[ rajco @ 14.10.2012. 09:37 ] @
Pod pretpostavkom da imate prava na računarima: Code: Set-ExecutionPolicy unrestricted
[ Machiavelli... @ 14.10.2012. 14:41 ] @
Kao sto rekoh, nije dozvoljeno na script execution niti mogu da promenim. To je jedna od company-wide polisa.
Venturu za predsednika! :-)
Pozz
Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|