send: zn "namespace"
...
send: set tTaskClassObj = ##class("class name").%New()
send: set tTaskClassObj.<subproperty> = "some value"
send: set tStatus = tTaskObj.AssignSettings(tTaskClassObj)
send: Kill tTaskClassObj
send: set tStatus = tTaskObj.%Save()

As I was using cache terminal this did work for me (and in my case changing namespace was needed as the class was present under that namespace otherwise it was throwing <CLASS DOES NOT EXIST>)

AWESOME!!! @ Eduard Lebedyuk, you saved the day.

And Thanks!! to both Eduard Lebedyuk & Jeffrey Drumm.

I can enjoy my weekend now.

I am actually trying to achieve task creation using Cache Terminal. Here is the bit of the script which does the work for me ..

send: Set tTaskObj = ##class(%SYS.Task).%New()
send: Set tTaskObj.NameSpace = "<NameSpace>" <CR>
send: Set tTaskObj.Name = "<tTaskName>" <CR>
send: Set tTaskObj.TaskClass = "<tTaskClass>" <CR>
send: Set tTaskObj.<subproperty>= "<subproperty>"<CR>
send: Set tTaskObj.Description = "<tTaskDesc>" <CR>
send: Set tStatus = tTaskObj.%Save() <CR>

The highlighted line is suppose that sub-property appears under the Task Type* .

But this is not doing anything helping me achieve the requirement.

myScript.scr

   zn "%SYS"
    for e="a","b","c" { w e,! }

use csession with linux PIPE (|) operator: 

cat myScript.scr | csession {instance_name}

Eg.

cat myScript.scr | csession CACHE

​​​​​Creating a separate file(extension doesn't matter as you are using "cat") when you have got large sequence of commands would be better.

​​​​​​

see my full solution http://stackoverflow.com/a/51599831/9454903