Written by

Development Analyst at Shift Consultoria e Sistemas
Question Thiago Zenaro · 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

Comments

Peter Smit · Oct 31, 2018

Might help if you change it to

ClassMethod MyMethod(pFilePath as %String)
0
Thiago Zenaro  Oct 31, 2018 to Sean Connelly

That is it!

Thank you Sean

0
Herman Slagman  Oct 31, 2018 to Sean Connelly

Six quotes :-O

Trial and error or is there any logic behind that ?

0
David Reche  Feb 13, 2019 to Sean Connelly

Yes please, I am curious about the logic behind this

0
Hans-Peter Iten  Feb 14, 2019 to Hans-Peter Iten

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

0
Sean Connelly · Oct 31, 2018

Hi Thiago,

Try

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

0
Hans-Peter Iten · Feb 14, 2019

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)

0