Topic
  • 18 replies
  • Latest Post - ‏2013-10-28T13:55:28Z by llandale
ZenMonkey760
ZenMonkey760
22 Posts

Pinned topic DXL "System" command on Windows

‏2010-02-24T18:52:16Z |
I would like to call the DXL "system" command to delete a directory structure on a Windows box as a quick way to start fresh on my database export. My script then recreates the directory structure and starts populating it with modules exported from the DOORS database.

The problem is that deleting hundreds of files and graphics along with all the folders takes several minutes and so I need the DXL to wait until it has finished before it continues to recreate the folder structure and populate. I couldn't find a way under Windows to get it to wait (the Unix version has a parent and child process for the system command but Windows doesn't.)

So, is there a way to force the DXL to wait until the DXL "system" command has completed?
Updated on 2011-01-25T08:56:19Z at 2011-01-25T08:56:19Z by ChidambaramL
  • Mathias Mamsch
    Mathias Mamsch
    2201 Posts

    Re: DXL "System" command on Windows

    ‏2010-02-24T19:02:11Z  

    You might want to try the

    int win32SystemWait_ (string commandString, string& sResult, int waitTime, Skip envString)
    

     


    perm which will do exactly what you want (I think waitTime=0 will make it wait forever) ...

    Regards, Mathias

     

    Updated on 2013-12-19T17:34:46Z at 2013-12-19T17:34:46Z by JAntley
  • ZenMonkey760
    ZenMonkey760
    22 Posts

    Re: DXL "System" command on Windows

    ‏2010-02-24T20:03:46Z  

    You might want to try the

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">int win32SystemWait_ (string commandString, string& sResult, int waitTime, Skip envString) </pre>

     


    perm which will do exactly what you want (I think waitTime=0 will make it wait forever) ...

    Regards, Mathias

     

    Where can I find some reference to this?

    How does it get used? I have tried a few different ways to call it, but got nothing but errors.
  • doors36677
    doors36677
    92 Posts

    Re: DXL "System" command on Windows

    ‏2010-02-24T20:07:14Z  
    Where can I find some reference to this?

    How does it get used? I have tried a few different ways to call it, but got nothing but errors.
    Here is perhaps a more useful form:

    int win32SystemWait_(string commandString,string& sResult, int waitTime)

    No documentation but you can find some reference on the old forum files.
  • llandale
    llandale
    3035 Posts

    Re: DXL "System" command on Windows

    ‏2010-02-24T20:31:19Z  
    I was unable to make that win32Wait stuff work; perhaps some Windows settings I do not understand. Other folks have used it with success.

    I've got a 'system' command that I must wait for, so after the 'system' call I just issue an 'ack(Wait for black window to close...). You could do the same, with some detailed instructions to the user about getting out and back into the folder to make sure its empty, and THEN OK the ack.

    • Louie
  • Mathias Mamsch
    Mathias Mamsch
    2201 Posts

    Re: DXL "System" command on Windows

    ‏2010-02-25T15:54:36Z  
    • llandale
    • ‏2010-02-24T20:31:19Z
    I was unable to make that win32Wait stuff work; perhaps some Windows settings I do not understand. Other folks have used it with success.

    I've got a 'system' command that I must wait for, so after the 'system' call I just issue an 'ack(Wait for black window to close...). You could do the same, with some detailed instructions to the user about getting out and back into the folder to make sure its empty, and THEN OK the ack.

    • Louie

    This works for me:
     

    string result = ""
    print win32SystemWait_ ("notepad.exe", result, -1)
    print "Thanks: " result "\n"
    

     


    Regards, Mathias

     

    Updated on 2013-12-19T17:35:37Z at 2013-12-19T17:35:37Z by JAntley
  • C124id
    C124id
    2 Posts

    Re: DXL "System" command on Windows

    ‏2011-01-22T15:58:58Z  

    Your post was helpful for us.

    We have a similar problem !!

    If you have deleted the Windows files from a DXL script, can you share the method with me. Following code does not work for me. I use a Windows XP OS - NTFS; we are trying to delete a file from a Windows share.

    This does not throw any error; a console pops-up and closes immediately.
     

    string Windows_Share = "//srti008a.xyz.com/Testing/*.*"
    string commandexe = "c:/windows/system32/cmd.exe /c del /Q /F " "\"" Windows_Share "\""
    system (commandexe)
    
    Updated on 2013-12-19T17:36:01Z at 2013-12-19T17:36:01Z by JAntley
  • Mathias Mamsch
    Mathias Mamsch
    2201 Posts

    Re: DXL "System" command on Windows

    ‏2011-01-22T17:36:07Z  
    • C124id
    • ‏2011-01-22T15:58:58Z

    Your post was helpful for us.

    We have a similar problem !!

    If you have deleted the Windows files from a DXL script, can you share the method with me. Following code does not work for me. I use a Windows XP OS - NTFS; we are trying to delete a file from a Windows share.

    This does not throw any error; a console pops-up and closes immediately.
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string Windows_Share = "//srti008a.xyz.com/Testing/*.*" string commandexe = "c:/windows/system32/cmd.exe /c del /Q /F " "\"" Windows_Share "\"" system (commandexe) </pre>

    I have never seen "/" used as a path separator on a windows shell. Maybe replace it by "\" ?

    This happens when I try on the shell:

    C:\>c:/windows/system32/cmd.exe /C "echo Hallo"
    Syntaxfehler.
     
    C:\>c:\windows\system32\cmd.exe /C "echo Hallo"
    Hallo
    

     


    Regards, Mathias

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

    Updated on 2013-12-19T17:36:31Z at 2013-12-19T17:36:31Z by JAntley
  • C124id
    C124id
    2 Posts

    Re: DXL "System" command on Windows

    ‏2011-01-24T10:37:29Z  

    I have never seen "/" used as a path separator on a windows shell. Maybe replace it by "\" ?

    This happens when I try on the shell:

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">C:\>c:/windows/system32/cmd.exe /C "echo Hallo" Syntaxfehler. C:\>c:\windows\system32\cmd.exe /C "echo Hallo" Hallo </pre>

     


    Regards, Mathias

     

     


    Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

     

    Thanks Mr.Mamsch !!
    It worked.
  • llandale
    llandale
    3035 Posts

    Re: DXL "System" command on Windows

    ‏2011-01-24T21:34:18Z  
    • C124id
    • ‏2011-01-22T15:58:58Z

    Your post was helpful for us.

    We have a similar problem !!

    If you have deleted the Windows files from a DXL script, can you share the method with me. Following code does not work for me. I use a Windows XP OS - NTFS; we are trying to delete a file from a Windows share.

    This does not throw any error; a console pops-up and closes immediately.
     

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">string Windows_Share = "//srti008a.xyz.com/Testing/*.*" string commandexe = "c:/windows/system32/cmd.exe /c del /Q /F " "\"" Windows_Share "\"" system (commandexe) </pre>
    You can delete a Windows file directly from DXL:
    string ErrMess = deleteFile(NameFileFull)

    • Louie
  • ChidambaramL
    ChidambaramL
    2 Posts

    Re: DXL "System" command on Windows

    ‏2011-01-25T08:56:19Z  
    • llandale
    • ‏2011-01-24T21:34:18Z
    You can delete a Windows file directly from DXL:
    string ErrMess = deleteFile(NameFileFull)

    • Louie

    Thanks !!

    Same is done through:

    Stat temp_folder = create <<Folder path of string type>>
    while (!(null temp_folder)) { 
        temp_folder = create folder_path 
    } //continue after the folder is deleted
    
    Updated on 2013-12-19T17:37:01Z at 2013-12-19T17:37:01Z by JAntley
  • jester76
    jester76
    68 Posts

    Re: DXL "System" command on Windows

    ‏2013-10-17T21:32:49Z  

    You might want to try the

    <pre class="javascript dw" data-editor-lang="js" data-pbcklang="javascript" dir="ltr">int win32SystemWait_ (string commandString, string& sResult, int waitTime, Skip envString) </pre>

     


    perm which will do exactly what you want (I think waitTime=0 will make it wait forever) ...

    Regards, Mathias

     

    Hello,

    Is there a way to supply arguement to this command. For example if I have to run a program and supply som arguements to it.

    This command does not seem to work.

    Please reply back if this can be done

    Thanks

    jester

  • Mathias Mamsch
    Mathias Mamsch
    2201 Posts

    Re: DXL "System" command on Windows

    ‏2013-10-18T10:02:30Z  
    • jester76
    • ‏2013-10-17T21:32:49Z

    Hello,

    Is there a way to supply arguement to this command. For example if I have to run a program and supply som arguements to it.

    This command does not seem to work.

    Please reply back if this can be done

    Thanks

    jester

    If you read that post to the end, there is actually an example for having arguments to the command. If in your special case it does not work, why not post some code? Regards, Mathias

  • jester76
    jester76
    68 Posts

    Re: DXL "System" command on Windows

    ‏2013-10-24T19:34:51Z  

    If you read that post to the end, there is actually an example for having arguments to the command. If in your special case it does not work, why not post some code? Regards, Mathias

    Sorry, here is the code:

    Object obj = current
    string sProbNumber1 = obj."A1"""
    string sProbNumber2 = obj."A2"""
    string strValue = ""
    string result = ""
    string strCMD =  "C:\\1Pradeep\\condoors.exe " "\"" sProbNumber1 "\" " "\"" sProbNumber2 "\" " "\"" "*" "\""

    system(strCMD) to be replaced with win32SystemWait(strCMD, string& sResult, int waitTime)

    If possible I want to hide the command windows flying around.

    Thanks

    Jester

    Updated on 2013-10-24T19:58:03Z at 2013-10-24T19:58:03Z by jester76
  • Mathias Mamsch
    Mathias Mamsch
    2201 Posts

    Re: DXL "System" command on Windows

    ‏2013-10-24T20:04:36Z  
    • jester76
    • ‏2013-10-24T19:34:51Z

    Sorry, here is the code:

    Object obj = current
    string sProbNumber1 = obj."A1"""
    string sProbNumber2 = obj."A2"""
    string strValue = ""
    string result = ""
    string strCMD =  "C:\\1Pradeep\\condoors.exe " "\"" sProbNumber1 "\" " "\"" sProbNumber2 "\" " "\"" "*" "\""

    system(strCMD) to be replaced with win32SystemWait(strCMD, string& sResult, int waitTime)

    If possible I want to hide the command windows flying around.

    Thanks

    Jester

    See this post for an alternative way to launch executables: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014702144. Maybe the shell.inc file can help you with the flying windows. The win32SystemWait uses the shell to launch commands, therefore you will always have shell windows flying around with this one.

    Regards, Mathias

     

  • jester76
    jester76
    68 Posts

    Re: DXL "System" command on Windows

    ‏2013-10-24T20:27:39Z  

    See this post for an alternative way to launch executables: https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014702144. Maybe the shell.inc file can help you with the flying windows. The win32SystemWait uses the shell to launch commands, therefore you will always have shell windows flying around with this one.

    Regards, Mathias

     

    Hi,

    I found this code other day and it does not seem to wait. Here is my code:

    Object obj = current
    string sProbNumber1 = obj."A1"""
    string sProbNumber2 = obj."A2"""
    string strValue = ""
    string result = ""
    string strCMD =  "C:\\1Pra\\condoors.exe " "\"" sProbNumber1 "\" " "\"" sProbNumber2 "\" " "\"" "*" "\""

    fnInvokeFile(strCMD)

    Stream fInput = read  "c:\\temp\\doorscal.txt"  // load path to variable
    flush fInput
    while (true)
    {
       fInput >> strValue
       if(end fInput) break
    }

    obj."A6" = strValue
    close fInput

    Added the following function in the inc.

    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - -
    void fnInvokeFile(string strArg)
    {
       Shell cmd  = create (strArg, true)
    }

    Am I doing anything wrong?

    I have a c# program doing calculations and storing them in a file.

     

  • Mathias Mamsch
    Mathias Mamsch
    2201 Posts

    Re: DXL "System" command on Windows

    ‏2013-10-24T20:48:36Z  
    • jester76
    • ‏2013-10-24T20:27:39Z

    Hi,

    I found this code other day and it does not seem to wait. Here is my code:

    Object obj = current
    string sProbNumber1 = obj."A1"""
    string sProbNumber2 = obj."A2"""
    string strValue = ""
    string result = ""
    string strCMD =  "C:\\1Pra\\condoors.exe " "\"" sProbNumber1 "\" " "\"" sProbNumber2 "\" " "\"" "*" "\""

    fnInvokeFile(strCMD)

    Stream fInput = read  "c:\\temp\\doorscal.txt"  // load path to variable
    flush fInput
    while (true)
    {
       fInput >> strValue
       if(end fInput) break
    }

    obj."A6" = strValue
    close fInput

    Added the following function in the inc.

    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - -
    void fnInvokeFile(string strArg)
    {
       Shell cmd  = create (strArg, true)
    }

    Am I doing anything wrong?

    I have a c# program doing calculations and storing them in a file.

     

    Double check if your program has really been executed! Invoke getStatus and getOutput to check if anything went wrong.  It might just seem, that it did not wait, just because the file was not created? Just run:

    Shell npad = create ("Notepad.exe", true /* wait */)

    The DXL program should freeze on your computer, waiting for Notepad to end. End Notepad and see, if the program unfreezes.  If it does not for you, then you might have a platform problem, which makes the Shell code not work on your side. Regards, Mathias

  • jester76
    jester76
    68 Posts

    Re: DXL "System" command on Windows

    ‏2013-10-25T00:30:47Z  
    • jester76
    • ‏2013-10-24T20:27:39Z

    Hi,

    I found this code other day and it does not seem to wait. Here is my code:

    Object obj = current
    string sProbNumber1 = obj."A1"""
    string sProbNumber2 = obj."A2"""
    string strValue = ""
    string result = ""
    string strCMD =  "C:\\1Pra\\condoors.exe " "\"" sProbNumber1 "\" " "\"" sProbNumber2 "\" " "\"" "*" "\""

    fnInvokeFile(strCMD)

    Stream fInput = read  "c:\\temp\\doorscal.txt"  // load path to variable
    flush fInput
    while (true)
    {
       fInput >> strValue
       if(end fInput) break
    }

    obj."A6" = strValue
    close fInput

    Added the following function in the inc.

    //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - -
    void fnInvokeFile(string strArg)
    {
       Shell cmd  = create (strArg, true)
    }

    Am I doing anything wrong?

    I have a c# program doing calculations and storing them in a file.

     

    It did work. but shell/command windows are flying.

    Is there a way to hide these windows

    Thanks

    Jester

  • llandale
    llandale
    3035 Posts

    Re: DXL "System" command on Windows

    ‏2013-10-28T13:55:28Z  
    • jester76
    • ‏2013-10-25T00:30:47Z

    It did work. but shell/command windows are flying.

    Is there a way to hide these windows

    Thanks

    Jester

    Is there perhaps a way to run the command window minimized?