Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

VB mali script ali ja ne znam VB :-(

[es] :: Skript jezici :: VB mali script ali ja ne znam VB :-(

[ Pregleda: 4824 | Odgovora: 15 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

Machiavelli...
Đorđe Đokanović
IT Support Engineer II
www.amazon.com
Philadelphia

Član broj: 90589
Poruke: 672
*.amazon.com.

Sajt: www.linkedin.com/in/dorde..


+92 Profil

icon VB mali script ali ja ne znam VB :-(11.10.2012. u 20:37 - pre 139 meseci
Ako neko ima vremena, nista hitno...

Potreban mi je script koji kad ga startujem

1. Pita me za IP
2. Ja ukucam IP

zatim on poskida 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

3. Sve to sredi u folder koji ima format ip.datum ili nesto slicno
4. I po mogustvu zipuje taj folder ( ovo nije neophodno ali bilo bi OK)

Ja sam ovo probao iz bash i laganica, doduse spakuje ga u tar.gz (sto je isto OK), ali niko ne koristi linux.

Ako nekog ne mrzi da pomogne, ako Vas mrzi razumecu.


Pozz
Having an idea is like being in a nutshell, but exchanging idea and collaborate
with
others is like being in infinite ocean of knowledge.
________________________________________________________________
____

Veruj u sebe. Ako ti neces, ko hoce?!

„Bolje živeti 100 godina kao milioner, nego sedam dana u bedi.“
 
Odgovor na temu

Machiavelli...
Đorđe Đokanović
IT Support Engineer II
www.amazon.com
Philadelphia

Član broj: 90589
Poruke: 672
*.hsd1.pa.comcast.net.

Sajt: www.linkedin.com/in/dorde..


+92 Profil

icon Re: VB mali script ali ja ne znam VB :-(12.10.2012. u 00:55 - pre 139 meseci
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...
Having an idea is like being in a nutshell, but exchanging idea and collaborate
with
others is like being in infinite ocean of knowledge.
________________________________________________________________
____

Veruj u sebe. Ako ti neces, ko hoce?!

„Bolje živeti 100 godina kao milioner, nego sedam dana u bedi.“
 
Odgovor na temu

Burgos
Nemanja Borić
Amazon Web Services
Berlin

Član broj: 12484
Poruke: 1947
..106.109.adsl.dyn.beotel.net.

Sajt: stackoverflow.com/users/1..


+480 Profil

icon Re: VB mali script ali ja ne znam VB :-(12.10.2012. u 01:10 - pre 139 meseci
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.
 
Odgovor na temu

Machiavelli...
Đorđe Đokanović
IT Support Engineer II
www.amazon.com
Philadelphia

Član broj: 90589
Poruke: 672
*.hsd1.pa.comcast.net.

Sajt: www.linkedin.com/in/dorde..


+92 Profil

icon Re: VB mali script ali ja ne znam VB :-(12.10.2012. u 01:28 - pre 139 meseci
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





Having an idea is like being in a nutshell, but exchanging idea and collaborate
with
others is like being in infinite ocean of knowledge.
________________________________________________________________
____

Veruj u sebe. Ako ti neces, ko hoce?!

„Bolje živeti 100 godina kao milioner, nego sedam dana u bedi.“
 
Odgovor na temu

Machiavelli...
Đorđe Đokanović
IT Support Engineer II
www.amazon.com
Philadelphia

Član broj: 90589
Poruke: 672
*.hsd1.pa.comcast.net.

Sajt: www.linkedin.com/in/dorde..


+92 Profil

icon Re: VB mali script ali ja ne znam VB :-(12.10.2012. u 18:48 - pre 139 meseci
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

Having an idea is like being in a nutshell, but exchanging idea and collaborate
with
others is like being in infinite ocean of knowledge.
________________________________________________________________
____

Veruj u sebe. Ako ti neces, ko hoce?!

„Bolje živeti 100 godina kao milioner, nego sedam dana u bedi.“
 
Odgovor na temu

reiser

Član broj: 7895
Poruke: 2314



+102 Profil

icon Re: VB mali script ali ja ne znam VB :-(12.10.2012. u 19:17 - pre 139 meseci
Unajmi nekog freelancera koji ce ti ovo otkucati za 30min u nekom jeziku :)
 
Odgovor na temu

Burgos
Nemanja Borić
Amazon Web Services
Berlin

Član broj: 12484
Poruke: 1947
..106.109.adsl.dyn.beotel.net.

Sajt: stackoverflow.com/users/1..


+480 Profil

icon Re: VB mali script ali ja ne znam VB :-(12.10.2012. u 22:38 - pre 139 meseci
Umesto prvog echoa

Code:
MkDir ""&result&"-"&datestr


umesto drugog

Code:
DeleteUrlCacheEntry "http://"&result&"/netcap0.log"
DownloadFile("http://"&result&"/netcap0.log", _
                             ""&result&"-"&datestr&"/netcap0.log")
 
Odgovor na temu

Machiavelli...
Đorđe Đokanović
IT Support Engineer II
www.amazon.com
Philadelphia

Član broj: 90589
Poruke: 672
*.amazon.com.

Sajt: www.linkedin.com/in/dorde..


+92 Profil

icon Re: VB mali script ali ja ne znam VB :-(12.10.2012. u 23:00 - pre 139 meseci
Probao sam vec sa ovim ali dobijam
'Variable is undefiend: 'MkDir'
Having an idea is like being in a nutshell, but exchanging idea and collaborate
with
others is like being in infinite ocean of knowledge.
________________________________________________________________
____

Veruj u sebe. Ako ti neces, ko hoce?!

„Bolje živeti 100 godina kao milioner, nego sedam dana u bedi.“
 
Odgovor na temu

Burgos
Nemanja Borić
Amazon Web Services
Berlin

Član broj: 12484
Poruke: 1947
..106.109.adsl.dyn.beotel.net.

Sajt: stackoverflow.com/users/1..


+480 Profil

icon Re: VB mali script ali ja ne znam VB :-(13.10.2012. u 00:03 - pre 139 meseci
Izvini, moja greška.

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
'za svaki folder, pozovi ovu funkciju - onu iznad samo jedanput. 
objFSO.CreateFolder ""&result&"-"&datestr 
 
Odgovor na temu

Machiavelli...
Đorđe Đokanović
IT Support Engineer II
www.amazon.com
Philadelphia

Član broj: 90589
Poruke: 672
*.amazon.com.

Sajt: www.linkedin.com/in/dorde..


+92 Profil

icon Re: VB mali script ali ja ne znam VB :-(13.10.2012. u 00:42 - pre 139 meseci
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
Having an idea is like being in a nutshell, but exchanging idea and collaborate
with
others is like being in infinite ocean of knowledge.
________________________________________________________________
____

Veruj u sebe. Ako ti neces, ko hoce?!

„Bolje živeti 100 godina kao milioner, nego sedam dana u bedi.“
 
Odgovor na temu

rajco

Član broj: 19348
Poruke: 1020

Sajt: rajco.me/blog


+45 Profil

icon Re: VB mali script ali ja ne znam VB :-(13.10.2012. u 00:47 - pre 139 meseci
Jesi li razmišljao da ovo uradiš preko PS-a? Bolje da učiš njega nego VB.
rajco.me/blog

 
Odgovor na temu

Machiavelli...
Đorđe Đokanović
IT Support Engineer II
www.amazon.com
Philadelphia

Član broj: 90589
Poruke: 672
*.amazon.com.

Sajt: www.linkedin.com/in/dorde..


+92 Profil

icon Re: VB mali script ali ja ne znam VB :-(13.10.2012. u 00:56 - pre 139 meseci
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.
Having an idea is like being in a nutshell, but exchanging idea and collaborate
with
others is like being in infinite ocean of knowledge.
________________________________________________________________
____

Veruj u sebe. Ako ti neces, ko hoce?!

„Bolje živeti 100 godina kao milioner, nego sedam dana u bedi.“
 
Odgovor na temu

ventura

Član broj: 32
Poruke: 7781
*.dynamic.sbb.rs.



+6455 Profil

icon Re: VB mali script ali ja ne znam VB :-(13.10.2012. u 13:15 - pre 139 meseci
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]
 
Odgovor na temu

Machiavelli...
Đorđe Đokanović
IT Support Engineer II
www.amazon.com
Philadelphia

Član broj: 90589
Poruke: 672
*.hsd1.pa.comcast.net.

Sajt: www.linkedin.com/in/dorde..


+92 Profil

icon Re: VB mali script ali ja ne znam VB :-(13.10.2012. u 15:38 - pre 139 meseci
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!
Having an idea is like being in a nutshell, but exchanging idea and collaborate
with
others is like being in infinite ocean of knowledge.
________________________________________________________________
____

Veruj u sebe. Ako ti neces, ko hoce?!

„Bolje živeti 100 godina kao milioner, nego sedam dana u bedi.“
 
Odgovor na temu

rajco

Član broj: 19348
Poruke: 1020

Sajt: rajco.me/blog


+45 Profil

icon Re: VB mali script ali ja ne znam VB :-(14.10.2012. u 09:37 - pre 139 meseci
Pod pretpostavkom da imate prava na računarima:
Code:
Set-ExecutionPolicy unrestricted

rajco.me/blog

 
Odgovor na temu

Machiavelli...
Đorđe Đokanović
IT Support Engineer II
www.amazon.com
Philadelphia

Član broj: 90589
Poruke: 672
*.hsd1.pa.comcast.net.

Sajt: www.linkedin.com/in/dorde..


+92 Profil

icon Re: VB mali script ali ja ne znam VB :-(14.10.2012. u 14:41 - pre 139 meseci
Kao sto rekoh, nije dozvoljeno na script execution niti mogu da promenim. To je jedna od company-wide polisa.
Venturu za predsednika! :-)

Pozz
Having an idea is like being in a nutshell, but exchanging idea and collaborate
with
others is like being in infinite ocean of knowledge.
________________________________________________________________
____

Veruj u sebe. Ako ti neces, ko hoce?!

„Bolje živeti 100 godina kao milioner, nego sedam dana u bedi.“
 
Odgovor na temu

[es] :: Skript jezici :: VB mali script ali ja ne znam VB :-(

[ Pregleda: 4824 | Odgovora: 15 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.