Jump to content
Drac89

Getting " subscript used on non accessible variable" for the below code , any idea why ?

Recommended Posts


 

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=ps_test.exe
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
#include <IE_v1.au3>

Func get_credentials($token)
    Local $aResult = DLLCall("pbpspassthru.dll", "str:cdecl", "pbps_get_credentials", "str", $token, "bool", 0)
    Local $credentials = StringSplit($aResult[0], " ")
    return $credentials
Endfunc

If $CmdLine[0] < 1 Then
   MsgBox($MB_OK, "Usage", "ps_Cisco_ISE<passthru_token>")
Else
   Cisco_ISE($CmdLine[1])
EndIf

;If $CmdLine[0] < 2 Then
   ;MsgBox($MB_OK, "Usage", "ps_Cisco_ISE <username> <password>")
;Else
   ;Cisco_ISE($CmdLine[1], $CmdLine[2])
;EndIf


Func Cisco_ISE($token)
;Func Cisco_ISE($email, $password)
    Local $credentials = get_credentials($token)

    Local $email = $credentials[1]
    Local $password = $credentials[2]
   Local $ie = _IECreate("https:///<IPdetails>, 1)

    Local $oIE = _IEAttach("Cert")
    _IELinkClickByText($oIE, "Continue to this website (not recommended).")

    If @error > 0 Then
      Local $i = 0

      Do
         Sleep(500)
         $i = $i + 1
         $ie = _IEAttach("<IPdetails>")
      Until VarGetType($ie) == "Object" Or $i >= 10
   EndIf

   If VarGetType($ie) == "Object" Then
      $hwnd = _IEPropertyGet($ie, "hwnd")
      WinSetState($hwnd, "", @SW_MAXIMIZE)
   ; Send the Username
    Send($email, 1)
   ; Ensure we are in the Password field
   Sleep(100)
   ; Send the Password
   Send("{TAB}")
   Send($password, 1)
   Sleep(10)
   ; Submit the credentials
   Send("{TAB}")
   Sleep(500)
   Send("{SPACE}")
   Send("{SPACE}")
   Send("{TAB}")
   Send("{ENTER}")
WinWaitClose($hwnd)
   Else
      MsgBox($MB_OK, "Login Failure", "Password Safe failed to automate the login. If this problem persists please contact your Password Safe Administrator.")
   EndIf

EndFunc ;==>Cisco_ISE()

 

Edited by Drac89

Share this post


Link to post
Share on other sites

Please first use au3check on you source as it does contain syntax errors!

...  and honestly: I wonder what you expect posting none runnable code and not providing the exact error details.

Jos

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
27 minutes ago, Drac89 said:

Hi

There is no syntax error I get. And the error detail is there in the title of this thread

Then you did not run the posted code through au3check...  so please do that now first.

Also: That posted error doesn't mean anything to me as that is from the compiled script.
Try running it from the SciTE editor as that will directly point you to the line in error.


SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

I have had exactly the same issue. It turns out the problem is the BT extension DLL is 64 bit and you must use the 64 bit au3toexe tool not the 32 bit version otherwise DLLCall will fail to load the DLL and returns 0 rather than the array you would expect hence the array in the StringSplit function is invalid.

Ian

Share this post


Link to post
Share on other sites

You have to check @error after DllCall()

here is fixed code which will not crash, instead show apropriate MsgBox() and return/exit (will not continue)

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile=ps_test.exe
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <Constants.au3>
#include <IE_v1.au3>

Func get_credentials($token)
    Local $aResult = DllCall("pbpspassthru.dll", "str:cdecl", "pbps_get_credentials", "str", $token, "bool", 0)
    If @error Then Return SetError(@error,0,@error)
    Local $credentials = StringSplit($aResult[0], " ")
    Return $credentials
EndFunc   ;==>get_credentials

If $CmdLine[0] < 1 Then
    MsgBox($MB_OK, "Usage", "ps_Cisco_ISE<passthru_token>")
Else
    Cisco_ISE($CmdLine[1])
EndIf

;If $CmdLine[0] < 2 Then
;MsgBox($MB_OK, "Usage", "ps_Cisco_ISE <username> <password>")
;Else
;Cisco_ISE($CmdLine[1], $CmdLine[2])
;EndIf

Func Cisco_ISE($token)
    ;Func Cisco_ISE($email, $password)
    Local $credentials = get_credentials($token)
    If @error Then Return MsgBox($MB_OK, "Get credentials Failure", "Error getting credentials (pbpspassthru.dll/pbps_get_credentials).")

    Local $email = $credentials[1]
    Local $password = $credentials[2]
    Local $ie = _IECreate("https:///<IPdetails>", 1)

    Local $oIE = _IEAttach("Cert")
    _IELinkClickByText($oIE, "Continue to this website (not recommended).")

    If @error > 0 Then
        Local $i = 0

        Do
            Sleep(500)
            $i = $i + 1
            $ie = _IEAttach("<IPdetails>")
        Until VarGetType($ie) == "Object" Or $i >= 10
    EndIf

    If VarGetType($ie) == "Object" Then
        $hwnd = _IEPropertyGet($ie, "hwnd")
        WinSetState($hwnd, "", @SW_MAXIMIZE)
        ; Send the Username
        Send($email, 1)
        ; Ensure we are in the Password field
        Sleep(100)
        ; Send the Password
        Send("{TAB}")
        Send($password, 1)
        Sleep(10)
        ; Submit the credentials
        Send("{TAB}")
        Sleep(500)
        Send("{SPACE}")
        Send("{SPACE}")
        Send("{TAB}")
        Send("{ENTER}")
        WinWaitClose($hwnd)
    Else
        MsgBox($MB_OK, "Login Failure", "Password Safe failed to automate the login. If this problem persists please contact your Password Safe Administrator.")
    EndIf

EndFunc   ;==>Cisco_ISE

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...