Doors Command Mode?

Can I run a DXL script from the command line on a specific module if the client is closed?

 

So I think, I have to assign the user and password, the path of the specific module in doors and the path of the dxl script?

 

Is there any possibility?


bandchef - Wed Dec 10 04:50:54 EST 2014

Re: Doors Command Mode?
Wolfgang Uhr - Wed Dec 10 07:35:04 EST 2014

Yes, there is a set of command line parameters for doors.

http://www-01.ibm.com/support/knowledgecenter/#!/SSYQBZ_9.5.0/com.ibm.doors.configuring.doc/topics/c_clientcommandswitches.html

Re: Doors Command Mode?
llandale - Wed Dec 10 18:22:33 EST 2014

This is batch mode, presumably the script does what it does and when done closes DOORS.

The tricky part here is getting the name of the module into the script.  I cannot think of a good way to do that right now, but using a "-D" dxl script to set some top-context variable "string MyModule = whatever" and then having your "-b" batch script use that variable, MyModule in this case.

-Louie

Re: Doors Command Mode?
tobi_mehrl - Wed Feb 04 08:59:33 EST 2015

llandale - Wed Dec 10 18:22:33 EST 2014

This is batch mode, presumably the script does what it does and when done closes DOORS.

The tricky part here is getting the name of the module into the script.  I cannot think of a good way to do that right now, but using a "-D" dxl script to set some top-context variable "string MyModule = whatever" and then having your "-b" batch script use that variable, MyModule in this case.

-Louie

Hi llandale,

 

thank you for your answer. When I use the -d, I get a warning on my console: Illegal Hostname in 'string MyModule = whatever' Press return to exti.

 

Where is the failure?

Re: Doors Command Mode?
Mathias Mamsch - Wed Feb 04 15:24:05 EST 2015

tobi_mehrl - Wed Feb 04 08:59:33 EST 2015

Hi llandale,

 

thank you for your answer. When I use the -d, I get a warning on my console: Illegal Hostname in 'string MyModule = whatever' Press return to exti.

 

Where is the failure?

The failure is that you do not follow along exactly. -d stands for --data and specifies the database you want to connect to. -D (uppercase!) stands for "--dxl" and means, execute some DXL.

I posted a walkthrough for a batch export script, that takes as a parameter here:

https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014305335&ps=25

Regards, Mathias

Re: Doors Command Mode?
tobi_mehrl - Thu Feb 05 02:27:21 EST 2015

Mathias Mamsch - Wed Feb 04 15:24:05 EST 2015

The failure is that you do not follow along exactly. -d stands for --data and specifies the database you want to connect to. -D (uppercase!) stands for "--dxl" and means, execute some DXL.

I posted a walkthrough for a batch export script, that takes as a parameter here:

https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014305335&ps=25

Regards, Mathias

Thank you for your answer.

Now I have changed -d to -D. Now I get a failure, that a false argument in line 1, that the Variable in line 1 is not propoer declared and a not proper associated token.

That is the Excel-line:

code:

wsh.Run "doors.exe -user " & myUsername & " -password " & myPassword & " -D ""string myModuleName = null; myModuleName = ""SFS_EM_VW_MQB_ABZ/"";"" -batch ""D:\myTest.dxl"" windowStyle, waitOnReturn"

- Is the dxl-code right written?

- The -batch switch is correct, because the script was in a previous version of this code called correctly.

 

The failure-code-line in the .dxl-File which is started through Excel is:

gmod_SSF = read("/.../.../..." myModuleName true, true)

That ist the line with the not proper associated token. Where is the failure??? With this line I would like instruct doors, that a hard coded path alwas the same until the last piece, which I would like have flexible with "myModuleName" and the information for myModuleName comes from the -D switch from Excel call.

 

How can I now transfer a string variable through the excel line? This way i would like prefer... What I have to do in the .dxl-file that the assigned string variable behind the -D switch will be assigned to the .dxl-file?

Re: Doors Command Mode?
Mathias Mamsch - Mon Feb 09 06:26:21 EST 2015

tobi_mehrl - Thu Feb 05 02:27:21 EST 2015

Thank you for your answer.

Now I have changed -d to -D. Now I get a failure, that a false argument in line 1, that the Variable in line 1 is not propoer declared and a not proper associated token.

That is the Excel-line:

code:

wsh.Run "doors.exe -user " & myUsername & " -password " & myPassword & " -D ""string myModuleName = null; myModuleName = ""SFS_EM_VW_MQB_ABZ/"";"" -batch ""D:\myTest.dxl"" windowStyle, waitOnReturn"

- Is the dxl-code right written?

- The -batch switch is correct, because the script was in a previous version of this code called correctly.

 

The failure-code-line in the .dxl-File which is started through Excel is:

gmod_SSF = read("/.../.../..." myModuleName true, true)

That ist the line with the not proper associated token. Where is the failure??? With this line I would like instruct doors, that a hard coded path alwas the same until the last piece, which I would like have flexible with "myModuleName" and the information for myModuleName comes from the -D switch from Excel call.

 

How can I now transfer a string variable through the excel line? This way i would like prefer... What I have to do in the .dxl-file that the assigned string variable behind the -D switch will be assigned to the .dxl-file?

You probably are not passing the quotes correctly to your commandline. Quotes inside a parameter (already quoted) need to be escaped by backslashes Check out the post on how the module name is passed on the command line:

https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014305335&ps=25

Regards, Mathias

Re: Doors Command Mode?
tobi_mehrl - Wed Feb 11 05:14:12 EST 2015

I won't use a extra batch-file for execute a DXL-codefile to transfer a variable from commandoline.

 

Can you show me a correct commandoline input for my problem without a batchfile?

Re: Doors Command Mode?
Mathias Mamsch - Wed Feb 11 06:14:57 EST 2015

tobi_mehrl - Wed Feb 11 05:14:12 EST 2015

I won't use a extra batch-file for execute a DXL-codefile to transfer a variable from commandoline.

 

Can you show me a correct commandoline input for my problem without a batchfile?

Its all in the mentioned post. Create a DXL file:

// test.dxl

print moduleName

Now open a command shell (cmd.exe) and execute:

doors.exe -b test.dxl -u <user> -P <password> -D "string moduleName=\"hallo welt\""

This is how you pass a parameter containing quotes over the command line. Since in the above posts (as I already wrote to you) the quotes inside the modulename are not escaped, you get DXL errors.

Regards, Mathias

Re: Doors Command Mode?
tobi_mehrl - Thu Feb 12 02:30:37 EST 2015

Mathias Mamsch - Wed Feb 11 06:14:57 EST 2015

Its all in the mentioned post. Create a DXL file:

// test.dxl

print moduleName

Now open a command shell (cmd.exe) and execute:

doors.exe -b test.dxl -u <user> -P <password> -D "string moduleName=\"hallo welt\""

This is how you pass a parameter containing quotes over the command line. Since in the above posts (as I already wrote to you) the quotes inside the modulename are not escaped, you get DXL errors.

Regards, Mathias

Thank you! The commandoline is running!

 

Now I have another question. With the -dxl switch you can assign dxl-code to doors. Can I write the dxl-code in a vba string-variable and assign this variable to the commandline?

Re: Doors Command Mode?
Mathias Mamsch - Thu Feb 12 03:21:46 EST 2015

tobi_mehrl - Thu Feb 12 02:30:37 EST 2015

Thank you! The commandoline is running!

 

Now I have another question. With the -dxl switch you can assign dxl-code to doors. Can I write the dxl-code in a vba string-variable and assign this variable to the commandline?

Yes, although I don't see why this is a problem once you know you simply need to escape your quotes...

doorsexe = """C:\Program Files (x86)\IBM\Rational\DOORS\9.5\bin\doors.exe"""
data     = " -d 36677@localhost"
login    = " -u Administrator"
batch    = " -b test.dxl" 

par = "Hallo VBA Welt"
DXL = " -D ""string moduleName=\""" & par & "\"""""


cmdline = doorsexe & data & DXL & login & batch
Wscript.Echo cmdline

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.run cmdline

Regards, Mathias

Re: Doors Command Mode?
tobi_mehrl - Thu Feb 12 03:33:57 EST 2015

Mathias Mamsch - Thu Feb 12 03:21:46 EST 2015

Yes, although I don't see why this is a problem once you know you simply need to escape your quotes...

doorsexe = """C:\Program Files (x86)\IBM\Rational\DOORS\9.5\bin\doors.exe"""
data     = " -d 36677@localhost"
login    = " -u Administrator"
batch    = " -b test.dxl" 

par = "Hallo VBA Welt"
DXL = " -D ""string moduleName=\""" & par & "\"""""


cmdline = doorsexe & data & DXL & login & batch
Wscript.Echo cmdline

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.run cmdline

Regards, Mathias

Thank you.

 

Can I also a complete DXL-script write in this way in Variable? Do I have a option to write from this DXL-script directly into Excel without a to make a detour over a temporarily .txt-file?

 

Do you have DXL scaffold code for this problem?

Re: Doors Command Mode?
Mathias Mamsch - Thu Feb 12 06:47:32 EST 2015

tobi_mehrl - Thu Feb 12 03:33:57 EST 2015

Thank you.

 

Can I also a complete DXL-script write in this way in Variable? Do I have a option to write from this DXL-script directly into Excel without a to make a detour over a temporarily .txt-file?

 

Do you have DXL scaffold code for this problem?

Well "print moduleName" is a complete DXL script - however the commandline has a limit of 32000 characters I think. It makes not a lot of sense to pass a complex DXL code over the command line. You would need to escape all kinds of characters making the DXL code impossible to maintain. Instead what you would do is to use a set of include files containing your library code. Then you just dynamically create your "main" code, using absolute includes for your library and then add the function calls.

And since files are on of the most reliable and stable DOORS interfaces that you have, using temp files is really the way to go here. There are other options though to transfer data from Excel<->DOORS. You can use the clipboard or the oleSetResult oleGetResult functions (I mentioned those already in an earlier post).

So regarding scaffold code I will not give you a complete working example, but a structure:

Library.dxl

// Library.dxl 

void exportModuleData (string Filename, string modulePath) {
    // read from module, write to file
    print "Exporting module " modulePath " to file " Filename "\n"
}

Script.vbs

// Script from VBS / VBA


public Function createTempFile () as String
    // create a temporary file and return it as String
    createTempFile = ...
End Function

public Function writeDXLMain (s as String) as String
    // write code to a temp file, put the absolute include path to the DXL library in there
    set strm = createTempFile(...)
    LibraryPath = ... absolute path of Library ... .replace("\", "/")
    strm.WriteLine "#include <" & LibraryPath & ">"
    strm.WriteLine s
    strm.close
    writeDXLMain = filename ...
End Sub

// 
public Sub executeDOORS (String s) 
   filename = writeDXLMain (s) 
   wsh.run filename // execute script file ...
   ... // delete script file ...
end Sub

Public Function EscapeString (String sContent)
    // return escaped string ...
End Function

public Function StringVar (String sName, String sContent) 
    StringVar = "string " & sName & " = """ & EscapeString(sContent) & """" & vbNewline
End Function

public Function StringArray (String sName, String sContent) 

    // return string array declaration 
    // string <sName>[] = { ... elements ... }
    // 
End Function


// main code ...
// for example 

// output of the script 
tempOutput = createTempFile() 

moduleNames = Array("/Module1", "/Module2", ...)

code = 
       StringVar ("outFile", tempOutput) &
       StringArrayVar ("moduleNames", modNames) & 
       "int i; for (i = 0; i < sizeof moduleNames; i++)"
       "exportModuleData(outFile, moduleName[i])"
       
      
executeDOORS code

I think this should give you an idea. Then what you need to do is implement and test your library functions. When it comes to exporting data from DOORS -> Excel the fastest thing you can use is a "TSV / CSV" format which you can directly set to an excel value. I think I already showed you an example post where that technique was demonstrated. In the example I used the clipboard by the way to transfer data (not a file).

Hope this gives you a start. Regards, Mathias