Domino 9 und frühere Versionen > Administration & Userprobleme

DB per Script in einem Agent öffnen

<< < (2/2)

Hoshee:
Yoo,

das Problem ist nur, das ich überprüfen will, ob der andere Server erreichbar ist (in dem ich eine DB öffne).
D.h. das mir eine Replic nicht hilft (zumal die Server sowieso geclustert sind)   :-/

Hat denn jemand eine andere Idee, wie ich die Verfügbarkeit testen/prüfen kann?

Rätselt immer noch ...

Hoshee

christoph_berger:
Moin Hoshee

Ein Mann genannt Ulrich Krause (--> EKnori?) postete einmal ein Stück Code mit dem man Server Commands ausführen kann. Vielleicht hilft dir das ja was ( e.g. sh task )

Gruss
Christoph

Link: http://searchdomino.techtarget.com/tip/1,289483,sid4_gci774870,00.html


Content:
Shortcut for executing server commands

Steve Holman
09 Oct 2001, Rating 4.53 (out of 5)

This tip is derived from a piece of code that was placed on the Notes.net Notes Gold Forum by Ulrich Krause. I modified it to make it easier for administrators to use and added functionality.

This is an example of how to send server task commands to a Domino Server using LotusScript and the WIN32 API. This allows for Administrators to use a form with a button, a view action, a form action, etc. to send commands to the server and in some cases see the results. Any "SHOW" command will show results, most others will come back with "Command Executed!" Follow the instructions below to set it up.

1. Create a blank form in a database. Name it anything you want.
2. Add a button to the form. The text for the button should be Console Command or something like that.
3. In the "Declarations" section of the button, copy and paste the code below.

Declare Function NSFRemoteConsole Lib "NNotes.dll" Alias "NSFRemoteConsole" (Byval Server As String, Byval cmd As String,
ret As Long) As Long
Declare Function OSLockObject Lib "NNotes.dll" Alias "OSLockObject"
(Byval Handle) As String
Declare Sub OSUnlockObject Lib "NNotes.dll" Alias "OSUnlockObject"
(Byval Handle)
Declare Sub OSMemFree Lib "NNotes.dll" Alias "OSMemFree" (Byval
Handle)
Class remoteConsole
     Private IsError As Variant
     Private rc As Integer
     Private hBuffer As Long
     Private Server As String
     Private Command As String
     Private Result As String
     
     Sub New(inpServer As String)
           Dim server As New NotesSession
           If inpServer = "" Then
                 Me.IsError = True
           Else
                 Me.server=inpServer
                 Me.IsError = False
           End If
     End Sub
     
     Function Execute(inpCommand As String, myserver As String) As String
           If Me.Server = "" Then
                 Me.Server = myserver
           End If
           If inpCommand = "" Then
                 Me.execute="You must specify a command"
                 Me.iserror = True
                 Exit Function
           Else
                 Me.command = inpCommand
           End If
           
           Me.rc = NSFRemoteConsole(Me.server, Me.command, hBuffer)
           If Me.rc <> 0 Then
                 Me.iserror = True
                 Me.result="Error returned " & _
                 " from console [" & Cstr(rc) & "]"
           Else
                 Me.result = OSLockObject(hBuffer)
                 Call OSUnlockObject(hBuffer)
                 Call OSMemFree(hBuffer)
                 Me.Iserror = False
           End If
           If Me.result = "" Then
                 Me.result = "Command executed!"
           End If
           Me.execute = Me.result
     End Function
End Class
4. In the "Click" section of the button, copy and paste the code below.

Sub Click(Source As Button)
     Dim exec As String
     Dim remConsole As New RemoteConsole("")
     'Dim ws As New NotesUIWorkspace
     'Dim uidoc As NotesUIDocument
     Dim myserver As String
     'Dim mydatabase As String
     
     'Set uidoc = ws.CurrentDocument
     myserver = Inputbox$("Type a server name", "Remote Console
Task", "<server>")
     'mydatabase = uidoc.FieldgetText( "RI_MailFileNm" )
     Exec = Inputbox$("Enter a remote console task", "Remote
Console Task", "Sh Ta")
     If exec = "" Then
           Exit Sub
     Else
           Msgbox remConsole.Execute(exec, myserver), 0, "Results"
     End If
End Sub
5. Save the form.
6. Open the database via the client and then choose Create --> Your Form(whatever you named your form).
7. Click the button and watch it work.

You can get creative from there. Just one of its uses from my site is that we use it in a portal we create a long while back in a Notes Database. It's a database on the Notes client that can do anything our administrators need to do at our site.

Thanks,

Steve



Code


Declare Function NSFRemoteConsole Lib
"NNotes.dll" Alias "NSFRemoteConsole" (Byval Server As String, Byval cmd As String, ret As Long) As Long
Declare Function OSLockObject Lib "NNotes.dll" Alias "OSLockObject"
(Byval Handle) As String
Declare Sub OSUnlockObject Lib "NNotes.dll" Alias "OSUnlockObject"
(Byval Handle)
Declare Sub OSMemFree Lib "NNotes.dll" Alias "OSMemFree" (Byval
Handle)
Class remoteConsole
     Private IsError As Variant
     Private rc As Integer
     Private hBuffer As Long
     Private Server As String
     Private Command As String
     Private Result As String
     
     Sub New(inpServer As String)
           Dim server As New NotesSession
           If inpServer = "" Then
                 Me.IsError = True
           Else
                 Me.server=inpServer
                 Me.IsError = False
           End If
     End Sub
     
     Function Execute(inpCommand As String, myserver As String)
As String
           If Me.Server = "" Then
                 Me.Server = myserver
           End If
           If inpCommand = "" Then
                 Me.execute="You must specify a command"
                 Me.iserror = True
                 Exit Function
           Else
                 Me.command = inpCommand
           End If
           
           Me.rc = NSFRemoteConsole(Me.server, Me.command,
hBuffer)
           If Me.rc <> 0 Then
                 Me.iserror = True
                 Me.result="Error returned " & _
                 " from console [" & Cstr(rc) & "]"
           Else
                 Me.result = OSLockObject(hBuffer)
                 Call OSUnlockObject(hBuffer)
                 Call OSMemFree(hBuffer)
                 Me.Iserror = False
           End If
           If Me.result = "" Then
                 Me.result = "Command executed!"
           End If
           Me.execute = Me.result
     End Function
End Class


Sub Click(Source As Button)
     Dim exec As String
     Dim remConsole As New RemoteConsole("")
     'Dim ws As New NotesUIWorkspace
     'Dim uidoc As NotesUIDocument
     Dim myserver As String
     'Dim mydatabase As String
     
     'Set uidoc = ws.CurrentDocument
     myserver = Inputbox$("Type a server name", "Remote Console
Task", "<server>")
     'mydatabase = uidoc.FieldgetText( "RI_MailFileNm" )
     Exec = Inputbox$("Enter a remote console task", "Remote
Console Task", "Sh Ta")
     If exec = "" Then
           Exit Sub
     Else
           Msgbox remConsole.Execute(exec, myserver), 0, "Results"
     End If
End Sub

Navigation

[0] Themen-Index

[*] Vorherige Sete

Zur normalen Ansicht wechseln