Question
· Oct 30, 2018

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

Discussion (7)3
Log in or sign up to continue

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)