Home > Community > Forums > Custom IC SKILL > $ sign doesn't work with ipcBeginProcess

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 $ sign doesn't work with ipcBeginProcess 

Last post Mon, Dec 14 2009 9:33 AM by Yaosan. 4 replies.
Started by Yaosan 11 Dec 2009 03:10 PM. Topic has 4 replies and 8319 views
Page 1 of 1 (5 items)
Sort Posts:
  • Fri, Dec 11 2009 3:10 PM

    • Yaosan
    • Top 500 Contributor
    • Joined on Fri, Aug 7 2009
    • Toronto, Ontario
    • Posts 35
    • Points 610
    $ sign doesn't work with ipcBeginProcess Reply

    I would like to run a command with $ sign in it with ipcBeginProcess but I cannot get it to work. For example:

    cmd = "perl -e '$i=1; print $i;'"
    cid = ipcBeginProcess(cmd)
    ipcWait(cid)
    ipcReadProcess(cid)

    The $i seems to be replaced by empty string when I do this. I tried putting in two $ sign to "escape" the sign but it doesn't work.

    Filed under:
    • Post Points: 20
  • Fri, Dec 11 2009 4:23 PM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,567
    • Points 15,575
    Re: $ sign doesn't work with ipcBeginProcess Reply

     Hi Yaosan,

    Have you tried escaping the "$" by preceding it with a backslash (or perhaps two backslashes - I have not checked in this case), e.g.

      cmd = "perl -e '\$i=1; print \$i;'"
    ;; may need this instead, uncomment if the above does not work
    ; cmd = "perl -e '\\$i=1; print \\$i;'"
    cid = ipcBeginProcess(cmd)
    ipcWait(cid)
    ipcReadProcess(cid)

    I hope that this helps!

    best regards,

    Lawrence.

    • Post Points: 20
  • Mon, Dec 14 2009 8:13 AM

    • Yaosan
    • Top 500 Contributor
    • Joined on Fri, Aug 7 2009
    • Toronto, Ontario
    • Posts 35
    • Points 610
    Re: $ sign doesn't work with ipcBeginProcess Reply

    Hi Lawrence,

    Thanks for the help, your commented line works, it's weird that you need double backslash to escape the $ sign. Still, I'm having trouble getting the following code to work:

      cmd = "perl -e '\\$i=\"abc def\"; print \\$i;'"

    cid = ipcBeginProcess(cmd)

    ipcWait(cid)

    ipcReadProcess(cid)

    It will complain that "Can't locate object method \"abc\" via package \"def\" (perhaps you forgot to load \"def\"?) at -e line 1.\n". I think the " sign doesn't show up when I run the command this way, thus "abc def" is not recognized as a string.

    • Post Points: 20
  • Mon, Dec 14 2009 8:38 AM

    • skillUser
    • Top 10 Contributor
    • Joined on Fri, Sep 19 2008
    • Austin, TX
    • Posts 2,567
    • Points 15,575
    Re: $ sign doesn't work with ipcBeginProcess Reply

     Hi Yaosan,

     Same thing as before, you may need to give a double backslash in front of the double-quote, again I have not tested it but try:

    
      cmd = "perl -e '\\$i=\\"abc def\\"; print \\$i;'"
    

     Hope it helps!

    Regards,

    Lawrence.

    • Post Points: 20
  • Mon, Dec 14 2009 9:33 AM

    • Yaosan
    • Top 500 Contributor
    • Joined on Fri, Aug 7 2009
    • Toronto, Ontario
    • Posts 35
    • Points 610
    Re: $ sign doesn't work with ipcBeginProcess Reply

    Hi Lawrence, thanks for the reply again. Double backslash doesn't work for quotes (it closes the string quotes prematurely), I tried triple backslash and it works! It's hard to read the input with that many backslash but it's all good now that I get it to work.

    Thanks!

    • Post Points: 5
Page 1 of 1 (5 items)
Sort Posts:
Started by Yaosan at 11 Dec 2009 03:10 PM. Topic has 4 replies.