Announcement

Collapse
No announcement yet.

Shell return

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shell return

    I'm using PBCC 2.0, older version but it works for me.

    Question is, I'm going to do a shell out based on the input.
    We're using the Oracle EM agent and I want to run a blackout on a specific database.

    So I formulate the shell command and all works.

    What if the EM agent command hangs?
    What kind of ERR can I look for?
    I feel kind of limited here....I cannot do this asynchronously, I need to wait for return.

    Here's an example:

    Code:
    If IsTrue Len(lCommand) Then
       cmd = LCase$(Parse$(lCommand," ",1))
       ORASID = Parse$(lCommand," ",2)
       CompName = Parse$(lCommand," ",-1)
    Else
       GoTo helpme
    End If
    
    wDebug = %TRUE
       'START COMMAND
    ShellCmd = "Emctl " & cmd & " blackout " & ORASID & "_INSTALL_DB " & ORASID & "." & CompName & ".domain.mil [img]http://www.powerbasic.com/support/forums/redface.gif[/img]racle_database"
    If IsTrue wDebug Then
       StdOut ShellCmd
    Else
       Shell ShellCmd
       Sleep 200
    End If
    ------------------
    Scott Turchin
    MCSE, MCP+I
    Computer Creations Software
    ----------------------
    Sometimes you give the world the best you got, and you get kicked in the teeth.
    Give the world the best you got anyway.
    - Ted Nugent (God, Guns, and Rock n' Roll)
    Scott Turchin
    MCSE, MCP+I
    http://www.tngbbs.com
    ----------------------
    True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

  • #2
    Hint:
    WaitForSingleObject with NON-INFINITE timeout.

    (Assuming there is some value of time which means the shelled program is 'hanging')


    Michael Mattias
    Tal Systems (retired)
    Port Washington WI USA
    [email protected]
    http://www.talsystems.com

    Comment


    • #3
      I had a feeling you'd say that but I don't have a working copy of that code here at work......

      Now, this will give me a return code, if the application sends one..........?

      I did have code here, this is my baseline code....haven't tou ched it in 7 years I'm sure LOL..

      Code:
      Function WaitShell(ByVal CmdLine As String) Export As Long
      Local Si        As STARTUPINFO
      Local Pi        As PROCESS_INFORMATION
      Local TimeLimit As Long
      Local Pid       As Dword
      
      TimeLimit = 30
      Si.cb = SizeOf(Si)
      Si.dwFlags = %STARTF_USESHOWWINDOW
      Si.wShowWindow = %SW_SHOWNORMAL
      
      Pid = CreateProcess("", _
                       ByVal StrPtr(CmdLine), _
                       ByVal %NULL, _
                       ByVal %NULL, _
                       0, _
                       %NORMAL_PRIORITY_CLASS, _
                       ByVal %NULL, _
                       ByVal %NULL, _
                       Si, _
                       Pi)
      If Pid Then
         Call WaitForInputIdle(pi.hProcess, %IGNORE)
         If TimeLimit Then
            Function = WaitForSingleObject(pi.hProcess, TimeLimit)
            Call CloseHandle(pi.hProcess)
            Call CloseHandle(pi.hThread)
         End If
      End If
      End Function
      ------------------
      Scott Turchin
      MCSE, MCP+I
      Computer Creations Software
      ----------------------
      Sometimes you give the world the best you got, and you get kicked in the teeth.
      Give the world the best you got anyway.
      - Ted Nugent (God, Guns, and Rock n' Roll)




      [This message has been edited by Scott Turchin (edited February 07, 2006).]
      Scott Turchin
      MCSE, MCP+I
      http://www.tngbbs.com
      ----------------------
      True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

      Comment


      • #4
        Now wasn't it more personally satisfying to find the answer yourself from a hint than to have someone just GIVE it to you?


        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          >Call WaitForInputIdle(pi.hProcess, %IGNORE)

          I don't see an "IGNORE" parameter for the timeout parameter for WaitForInputIdle. All my SDK doc shows is "milliseconds" or INFINITE as valid values for the timeout amount.

          May I have a value or documentation reference, please?
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment

          Working...
          X