+ Post New Thread
Page 1 of 2 12 LastLast
Results 1 to 15 of 24
MIS Systems Thread, help in running sims commandreporter (yet again!) in Technical; I am trying to use CR with parameters to limit dates. If I make the paramdef xml file using the ...
  1. #1

    Join Date
    Mar 2007
    Posts
    39
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    16

    help in running sims commandreporter (yet again!)

    I am trying to use CR with parameters to limit dates.
    If I make the paramdef xml file using the \PARAMDEF switch, alter the dates in it and use a batch file to run CR with the \PARAMFILE parameter pointing at the file it works OK.

    However, (trying to avoid using the file) if instead I take the contents of the xml file and simply pass that entire string as a \PARAMS parameter CR gives me this error.

    '1.0' is an unexpected token. The expected token is '"' or ''' Line 1, Position 15.
    That corresponds to the first part of the xml where it states the version i.e
    Code:
    /PARAMS:"<?xml version="1.0" encoding="us-ascii"?><ReportParameters><xs:schema id='ReportParameters' xmlns:xs='http://www.w3.org/2001/XMLSchema' ....etc.
    Has anyone used \PARAMS sucessfully?

    BTW I would prefer to do it with a \PARAMS instead of PARAMSFILE as in my real application I use a Delphi program to call CR, not a batch file. However that seems to fail if I use either the /PARAMFILE or /PARAM swich, but works OK if I dont use parameters at all.

    Howard

  2. #2

    vikpaw's Avatar
    Join Date
    Sep 2006
    Location
    Saudi Arabia
    Posts
    5,765
    Thank Post
    713
    Thanked 1,435 Times in 1,188 Posts
    Rep Power
    359
    Can you just omit the XML declaration tag, and pass in only the report parameters tags onwards. Remove the xml closing tag too.

  3. #3

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,559
    Thank Post
    1,467
    Thanked 1,219 Times in 828 Posts
    Rep Power
    752
    The problem is that on the command line, when it reaches a quotation (") it thinks that's the end of your literal input. So you need to escape any quotations that must be included by doubling them up, for instance the above example would become:

    Code:
    /PARAMS:"<?xml version=""1.0"" encoding=""us-ascii""?><ReportParameters><xs:schema id='ReportParameters' xmlns:xs='http://www.w3.org/2001/XMLSchema' ....etc.
    Personally, I find it easier to construct my XML in code and dump it to an XML file and pass that as an argument

  4. #4

    Join Date
    Mar 2007
    Posts
    39
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    16
    Hi vikpaw,
    I tried it with just
    /PARAMS:"<Parameter id="DDNzGLsaAUi8eGtd+3PIGw==" subreportfilter="True"> <Name>Mark date</Name> <Type>Date</Type> <PromptText>MarkDateBefore</PromptText> <Values> <Date>2011-06-09T00:01:00</Date> </Values> </Parameter> <Parameter id="eNvt6kqoTcUAoHB2VMyWRg==" subreportfilter="True"> <Name>Mark date</Name> <Type>Date</Type> <PromptText>MarkDateAfter</PromptText> <Values> <Date>2010-08-15T23:59:00</Date> </Values> </Parameter>"
    and this time got an unrecognised token on DDNzGLsaAUi8eGtd+3PIGw==

    Howard

  5. #5

    vikpaw's Avatar
    Join Date
    Sep 2006
    Location
    Saudi Arabia
    Posts
    5,765
    Thank Post
    713
    Thanked 1,435 Times in 1,188 Posts
    Rep Power
    359
    My bad @iceman - i was just guessing. @LosOjos has the answer i reckon with needing to escape the quote marks. Sometimes using double instead of single can do the trick.

    I think passing the file would make more sense otherwise you're going to have to hack around with the quotes. I feel another script coming on...

  6. #6

    Join Date
    Mar 2007
    Posts
    39
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    16
    Vikpaw, You were right you can just use the bits from the <Parameter> to the </Parameter> - at least on the command line you can
    . I also doubled up the quotes just in case but it didn't seem to matter if I did or not it still ran OK. Thanks for getting it shorter.

    The odd thing is that I still cannot get it to run from a Delphi program using CreateProcess() . This function should run an external program and pass it parameters.
    It works fine when I use it to run CR with the user, pw and output parameters but fails if I pass the Params one as well, even though I copy paste the string that works fine on the command line.
    Something is very odd.
    Howard

  7. #7

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,559
    Thank Post
    1,467
    Thanked 1,219 Times in 828 Posts
    Rep Power
    752
    Quote Originally Posted by iceman View Post
    The odd thing is that I still cannot get it to run from a Delphi program using CreateProcess() . This function should run an external program and pass it parameters.
    It works fine when I use it to run CR with the user, pw and output parameters but fails if I pass the Params one as well, even though I copy paste the string that works fine on the command line.
    Something is very odd.
    You seriously do need to escape your characters, I'm shocked it runs on the command line without doing so, but you'll have to look up how to escape characters in Delphi (a quick Google suggests it's doubling up the character as I said previously)

  8. #8

    Join Date
    Mar 2007
    Posts
    39
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    16
    They are all escaped. As a debug I write out the parameters being passed to CreateProcess just before it runs. The relevant one is
    /PARAMS:" <Parameter> <Parameter id=""DDNzGLsaAUi8eGtd+3PIGw=="" subreportfilter=""True""> <Name>Mark date</Name> <Type>Date</Type> <PromptText>MarkDateBefore</PromptText> <Values> <Date>2011-06-09T00:01:00</Date> </Values> </Parameter> <Parameter> <Parameter id=""eNvt6kqoTcUAoHB2VMyWRg=="" subreportfilter=""True""> <Name>Mark date</Name> <Type>Date</Type> <PromptText>MarkDateAfter</PromptText> <Values> <Date>2010-08-15T23:59:00</Date> </Values> </Parameter>"
    the whole thing is enclosed in single quotes as required by CR.

    I also wrote a dummy commandreporter.exe that simply wrote out the parameters it was being sent. Interestingly it claimed to get
    /PARAMS: <Parameter> <Parameter id=DDNzGLsaAUi8eGtd+3PIGw== subreportfilter=True> <Name>Mark date</Name> <Type>Date</Type> <PromptText>MarkDateBefore</PromptText> <Values> <Date>2011-6-13T00:01:00</Date> </Values> </Parameter> <Parameter> <Parameter id=eNvt6kqoTcUAoHB2VMyWRg== subreportfilter=True> <Name>Mark date</Name> <Type>Date</Type> <PromptText>MarkDateAfter</PromptText> <Values> <Date>2010-8-15T23:59:00</Date> </Values> </Parameter>
    so its possible that either CreateProcess or the mechanism by which a program extracts its parameters is stripping out even escaped double quotes.

  9. #9

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,559
    Thank Post
    1,467
    Thanked 1,219 Times in 828 Posts
    Rep Power
    752
    Seems odd... what is the reason that you can't just dump it in to an XML and pass the XML file as the argument? That's what I always do as I gave up battling with getting it to run from the command line a long time ago

  10. #10

    nickbro's Avatar
    Join Date
    Jul 2010
    Location
    Gilwern, Wales
    Posts
    3,628
    Thank Post
    39
    Thanked 528 Times in 456 Posts
    Rep Power
    118
    Quote Originally Posted by iceman View Post
    They are all escaped. As a debug I write out the parameters being passed to CreateProcess just before it runs. The relevant one is

    the whole thing is enclosed in single quotes as required by CR.

    I also wrote a dummy commandreporter.exe that simply wrote out the parameters it was being sent. Interestingly it claimed to get


    so its possible that either CreateProcess or the mechanism by which a program extracts its parameters is stripping out even escaped double quotes.

    Try

    Code:
    /PARAMS:"<ReportParameters><Parameter><Parameter  id='DDNzGLsaAUi8eGtd+3PIGw==' subreportfilter='True'><Name>Mark date</Name><Type>Date</Type> <PromptText>MarkDateBefore</PromptText><Values><Date>2011-06-09T00:01:00</Date></Values></Parameter><Parameter><Parameter  id='eNvt6kqoTcUAoHB2VMyWRg==' subreportfilter='True'><Name>Mark date</Name><Type>Date</Type><PromptText>MarkDateAfter</PromptText><Values><Date>2010-08-15T23:59:00</Date></Values></Parameter></ReportParameters>"
    It's all down the the quote marks, dos only sees the double quotes, so if you use "" it will just see end of one quote start of another, which it doesn't like. Using ' instead gets around this.

  11. #11

    LosOjos's Avatar
    Join Date
    Dec 2009
    Location
    West Midlands
    Posts
    5,559
    Thank Post
    1,467
    Thanked 1,219 Times in 828 Posts
    Rep Power
    752
    Quote Originally Posted by nickbro View Post
    Try

    Code:
    /PARAMS:"<ReportParameters><Parameter><Parameter  id='DDNzGLsaAUi8eGtd+3PIGw==' subreportfilter='True'><Name>Mark date</Name><Type>Date</Type> <PromptText>MarkDateBefore</PromptText><Values><Date>2011-06-09T00:01:00</Date></Values></Parameter><Parameter><Parameter  id='eNvt6kqoTcUAoHB2VMyWRg==' subreportfilter='True'><Name>Mark date</Name><Type>Date</Type><PromptText>MarkDateAfter</PromptText><Values><Date>2010-08-15T23:59:00</Date></Values></Parameter></ReportParameters>"
    It's all down the the quote marks, dos only sees the double quotes, so if you use "" it will just see end of one quote start of another, which it doesn't like. Using ' instead gets around this.
    I'm interested to see if that works, as that would actually make the XML volatile which should mean it's rejected...

  12. #12

    Join Date
    Mar 2007
    Posts
    39
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    16
    OK I've tried runing it via the dos prompt with single quotes and even no quotes! both work OK
    However when I pass the same command line to CreateProcess it fails to run CR claiming a file handle error.
    Passing the same command line to createprocess but ommiting the Params parameter works OK.
    Putting the xml in a file also works OK from the dos prompt but once again fails when CR is called via createProcess and the filename is passed (Thats why I was trying this alternative approach)

    Howard

  13. #13

    nickbro's Avatar
    Join Date
    Jul 2010
    Location
    Gilwern, Wales
    Posts
    3,628
    Thank Post
    39
    Thanked 528 Times in 456 Posts
    Rep Power
    118
    Quote Originally Posted by LosOjos View Post
    I'm interested to see if that works, as that would actually make the XML volatile which should mean it's rejected...
    It does work, as I use it in several SIMS report apps that I've made to update stuff on our computer system. XML will work with single or double quote, most people use double, but single is perfectly fine.

  14. Thanks to nickbro from:

    LosOjos (13th June 2011)

  15. #14

    vikpaw's Avatar
    Join Date
    Sep 2006
    Location
    Saudi Arabia
    Posts
    5,765
    Thank Post
    713
    Thanked 1,435 Times in 1,188 Posts
    Rep Power
    359
    Quote Originally Posted by iceman View Post
    OK I've tried runing it via the dos prompt with single quotes and even no quotes! both work OK
    However when I pass the same command line to CreateProcess it fails to run CR claiming a file handle error.
    Passing the same command line to createprocess but ommiting the Params parameter works OK.
    Putting the xml in a file also works OK from the dos prompt but once again fails when CR is called via createProcess and the filename is passed (Thats why I was trying this alternative approach)

    Howard

    I thought there was a way to pass parameters direct, so at least that worked. Now thinking in psuedo code:

    It seems delphi or the createprocess() function wants the parameters a certain way. How does it function for say running a 'dir' command...?

    Does wrapping the whole lot in quotes make any difference?

    Can you get Delphi to just call the batch file, so directly or using createprocess() on the CR.bat that does work...?

    If escaping the quotes doesn't work how about interchanging the double and single, if possible within the limitation mentioned above about only one type being recognised. I think i recall, in one particularly complicated html / php code i wrote, i had 3 levels of embedded quotes, and rather than escape them, it was necessary for the master level to be single, then sub params double and then the embedded ones to be single again. It's damned hard to read (and troubleshoot) but does do the trick.

    Maybe if you can replicated the issues with commandreporter with another simpler program with less complex parameter requirements you can test a few things out.

  16. #15

    Join Date
    Mar 2007
    Posts
    39
    Thank Post
    0
    Thanked 2 Times in 2 Posts
    Rep Power
    16
    Sorted it. It was not Createprocess at all. the folder in which I was running my app and into which I was writing the xml file was hidden with read/write acces only to me. It appears that when CR gets run by CreateProcess it runs using different credientials. Moving everything to a different folder worked OK.

    However I'll leave a challenge to the community. As Vikpaw says, It would be better to use the /PARAMS: switch instead and place the xml directly after it (as one big quoted string) to avoid having to write an xml file at all.
    Problem is the xml contains spaces and quotes. Createprocess parses the line and does some quote stripping and so does the command line interpretor before it passess the arguments to commandreporter.

    Challenge
    Find the correct sequence of escapes to generate a command string that can be passed to CreateProcess() to run a report via commandreporter with the following argument !

    Code:
    /PARAMS:"
    <?xml version="1.0" encoding="us-ascii"?>
    <ReportParameters>
        <Parameter id="DDNzGLsaAUi8eGtd+3PIGw==" subreportfilter="True">
            <Name>Mark date</Name>
            <Type>Date</Type>
            <PromptText>MarkDateBefore</PromptText>
            <Values>
                <Date>2011-06-10T00:01:00</Date>
            </Values>
        </Parameter>
        <Parameter id="eNvt6kqoTcUAoHB2VMyWRg==" subreportfilter="True">
            <Name>Mark date</Name>
            <Type>Date</Type>
            <PromptText>MarkDateAfter</PromptText>
            <Values>
                <Date>2010-08-15T23:59:00</Date>
            </Values>
        </Parameter>
        </ReportParameters>"
    Last edited by iceman; 11th June 2011 at 08:14 AM. Reason: spelling!

SHARE:
+ Post New Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. sims.net commandreporter
    By oxide54 in forum MIS Systems
    Replies: 6
    Last Post: 23rd November 2010, 11:41 AM
  2. SIMS ID Interface / CommandReporter Example
    By LosOjos in forum MIS Systems
    Replies: 10
    Last Post: 7th June 2010, 01:51 PM
  3. Need a way of running SIMS
    By sidewinder in forum Mac
    Replies: 14
    Last Post: 8th December 2009, 03:06 PM
  4. SIMS.Net CommandReporter scheduled doesn't work
    By u8dmtm in forum MIS Systems
    Replies: 9
    Last Post: 8th January 2009, 11:07 AM
  5. Running Sims standalone?
    By Outpost in forum MIS Systems
    Replies: 1
    Last Post: 11th September 2007, 09:30 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •