wie im Thread (viewtopic.php?f=6&t=9718) bereits angedeutet, bin ich gerade dabei, die neuen Funktionen mit lokalen Variablen auszuprobieren.
Dabei ist mir noch nachfolgender Bug aufgefallen, wenn in der ausgelagerten Funktion IF-Schleifen vorkommen. Dann wird das eigentliche Hauptscript nicht mehr weiterverarbeitet, wenn hier die Funktion ebenfalls innerhalb einer IF-Schleife aufgerufen wird.
Hier das Beispiel Hauptscript:
Code: Alles auswählen
encoding=UTF-8
[Actions]
DefVar $Var1$
DefVar $Var2$
DefVar $exitcode$
set $Var1$ = "1"
set $Var2$ = "2"
importLib "function-global-test.opsiscript"
if ($Var1$ = "1")
set $exitcode$ = function-test($Var1$)
comment $exitcode$
if ($Var2$ = "2")
comment $Var2$
endif
endif
Code: Alles auswählen
DefFunc function-test($VarSub1$ : string) : string
set $result$ = $VarSub1$
if ($result$ = "1")
comment "Result ist okay"
else
comment "Result ist nicht okay"
endif
endfunc
Code: Alles auswählen
============ Version 4.12.0.7 script "p:\test\setup.opsiscript"
[1] [Nov 28 12:00:54:321] [test] used script encoding: UTF-8
[1] [Nov 28 12:00:54:321] [test] used system encoding: cp1252
[1] [Nov 28 12:00:54:321] [test] start: 2017-11-28 12:00:54
[1] [Nov 28 12:00:54:321] [test] installing product: test_1.0-1
[1] [Nov 28 12:00:54:321] [test] on client named "xxx"
[1] [Nov 28 12:00:54:321] [test] loggedin user ""
[1] [Nov 28 12:00:54:321] [test] opsi-script running as "SYSTEM"
[1] [Nov 28 12:00:54:321] [test] opsi-script running with admin privileges
[1] [Nov 28 12:00:54:321] [test] opsi-script running in standard script mode
[1] [Nov 28 12:00:54:321] [test] executing: "C:\Program Files (x86)\opsi.org\opsi-client-agent\opsi-winst\winst32.exe"
[1] [Nov 28 12:00:54:321] [test] system infos:
[1] [Nov 28 12:00:54:326] [test] xxx - PC hardware address
[1] [Nov 28 12:00:54:326] [test] xxx - IP name
[1] [Nov 28 12:00:54:326] [test] xxx - IP address
[1] [Nov 28 12:00:54:326] [test] DEU - System default locale
[1] [Nov 28 12:00:54:326] [test] MS Windows 6.1 64 Bit, Edition: Server Enterprise Edition (full installation)
[1] [Nov 28 12:00:54:326] [test] opsi service version : 4
[1] [Nov 28 12:00:54:326] [test]
[7] [Nov 28 12:00:54:327] [test] Registry started readonly
[7] [Nov 28 12:00:54:327] [test] Registry started without redirection (64 Bit)
[6] [Nov 28 12:00:54:328] [test] Registry key [HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion] opened
[6] [Nov 28 12:00:54:328] [test] Key closed
[6] [Nov 28 12:00:54:418] [test] Set $Var1$ = "1"
[6] [Nov 28 12:00:54:418] [test] The value of the variable "$Var1$" is now: "1"
[6] [Nov 28 12:00:54:418] [test] Set $Var2$ = "2"
[6] [Nov 28 12:00:54:418] [test] The value of the variable "$Var2$" is now: "2"
[7] [Nov 28 12:00:54:418] [test] Found ImportLib statement for file: function-global-test.opsiscript and function:
[5] [Nov 28 12:00:54:439] [test] Imported all functions from file: p:\lib\function-global-test.opsiscript
[6] [Nov 28 12:00:54:441] [test] Added defined function:: function-unzip to the known functions
[6] [Nov 28 12:00:54:441] [test] If
[7] [Nov 28 12:00:54:441] [test] $Var1$ = "1" <<< result true
[6] [Nov 28 12:00:54:442] [test] ($Var1$ = "1") <<< result true
[6] [Nov 28 12:00:54:442] [test] Then
[6] [Nov 28 12:00:54:442] [test] Set $exitcode$ = function-test($Var1$)
[6] [Nov 28 12:00:54:442] [test] Set $result$ = $VarSub1$
[6] [Nov 28 12:00:54:442] [test] The value of the variable "$result$" is now: "1"
[6] [Nov 28 12:00:54:442] [test] If
[7] [Nov 28 12:00:54:442] [test] $result$ = "1" <<< result true
[6] [Nov 28 12:00:54:442] [test] ($result$ = "1") <<< result true
[6] [Nov 28 12:00:54:442] [test] Then
[5] [Nov 28 12:00:54:442] [test] comment: Result ist okay
[6] [Nov 28 12:00:54:442] [test] Else
[6] [Nov 28 12:00:54:442] [test] EndIf
[6] [Nov 28 12:00:54:442] [test] The value of the variable "$exitcode$" is now: "1"
[6] [Nov 28 12:00:54:442] [test] If
[6] [Nov 28 12:00:54:442] [test] Then
[6] [Nov 28 12:00:54:442] [test] EndIf
[6] [Nov 28 12:00:54:442] [test] EndIf
[1] [Nov 28 12:00:54:443] [test] ___________________
[1] [Nov 28 12:00:54:443] [test] script finished: success
[1] [Nov 28 12:00:54:443] [test] 0 errors
[1] [Nov 28 12:00:54:443] [test] 0 warnings
[1] [Nov 28 12:00:54:443] [test]
[1] [Nov 28 12:00:54:443] [test] installed product: test Version: 1.0-1
[1] [Nov 28 12:00:54:443] [test]
Code: Alles auswählen
comment $exitcode$
if ($Var2$ = "2")
comment $Var2$
endif
Bitte um Info, wenn ich das Problem zu umständlich erklärt habe
Versionen:
opsi Server = 4.0.7.45
opsi-client-agent = 4.0.7.23-4
opsi-winst = 4.12.0.7-1
Viele Grüße
Leonardo