csession with ##class command on a Windows machine

Hi community.

I'm trying to create a "setup" method to be called on a batch script but i'm getting the error <INVALID ARGUMENT> when I pass a string as an argument to this method.

The idea is to call the method with a folder as the parameter, for example:

##class(test.MyClass).MyMethod("D:\path\to\my\file.json")
 

My class (just for example)

Class test.MyClass

{

ClassMethod MyMethod(pFilePath)
{
Write pFilePath ,!
}

}

I'm using cmd as follows:

D:\>csession CACHE20172 -U %SYS ##class(test.MyClass).MyMethod(100)
100

If I use a number, It works, but any string value I get the error

D:\>csession CACHE20172 -U %SYS ##class(test.MyClass).MyMethod("test")

<INVALID ARGUMENT>>
D:\>csession CACHE20172 -U %SYS ##class(test.MyClass).MyMethod(\"test\")

<INVALID ARGUMENT>>
D:\>csession CACHE20172 -U %SYS ##class(test.MyClass).MyMethod(^"test^")

<INVALID ARGUMENT>>
D:\>csession CACHE20172 -U %SYS ##class(test.MyClass).MyMethod(""test"")

<INVALID ARGUMENT>>
D:\>csession CACHE20172 -U %SYS "##class(test.MyClass).MyMethod(\"test\")"

<INVALID ARGUMENT>>
D:\>csession CACHE20172 -U %SYS "##class(test.MyClass).MyMethod(^"test^")"

<INVALID ARGUMENT>>
D:\>csession CACHE20172 -U %SYS "##class(test.MyClass).MyMethod("""test""")"

<INVALID ARGUMENT>>

Any idea to solve this? I think it might be something very easy (maybe related to escaping chars), but i'm stuck with this for some hours.

On a Linux machine I could make it work, but on a Windows machine I was not able so far...

Thank you all

  • 0
  • 0
  • 426
  • 5
  • 2

Answers

Hi Thiago,

Try

D:\>csession CACHE20172 -U %SYS "##class(test.MyClass).MyMethod(""""""test"""""")"

Six quotes :-O

Trial and error or is there any logic behind that ?

Yes please, I am curious about the logic behind this

Might help if you change it to

ClassMethod MyMethod(pFilePath as %String)

Comments

How would you do that with PowerShell?:

PS C:\InterSystems\Cache\bin> .\csession mycache -"U" user "##class(test.OsCall).inString(""""""abd"""""")"

<INVALID ARGUMENT>>
PS C:\InterSystems\Cache\bin>

Combination of escape-characters doesn't work like these "##class.....(\`"abd\`")" or "##class....(`"abd`")"

compared to CMD:

C:\Users\me> .\csession myCache -"U" user "##class(test.OsCall).inString(""""""abd"""""")"  //see Seans good answer


Argument read: abd  (this comes from my Caché-class, so this environment works properly)

I solved this problem myself:

Suppose you switched (cd) into bin-directory of caché installation:

PS> .\csession myCache -U myNamespace "##class(test.OsCall).inString(""""""""""""""$string"""""""""""""")"

$string contains some text