Passing variabl to a shell task

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2014 08:20 AM
I'm using Activiti-rest and having a hard time figuring out how to use variables in a shell task.
I create a process instance using POST runtime/process-instances:
{ 'processDefinitionId':'xxxxx', 'variables' : [ {'name' : 'myVar', 'value' : 'something'} ]}
And my process definition contains:
<serviceTask id="console" activiti:type="shell" > <extensionElements> <activiti:field name="command" stringValue="echo" /> <activiti:field name="arg1" stringValue="${scriptVar}" /> </extensionElements></serviceTask>
But this doesn't work. The process runs properly otherwise.
Any help would be appreciated.
- Labels:
-
Archive

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2014 08:21 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2014 11:49 AM
Best regards,

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2014 09:20 PM
By "this doesn't work" I mean that ${myVar} seems null. As a testable example we could say that if we defined myVar = /tmp/thing.txt
then when trying the above replacing "echo" with "touch" then
touch ${myVar} should create a file but doesn't
If I replace ${myVar} by the actual path I get :
touch /tmp/thing.txt And this works correctly and creates the file.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2014 02:08 PM
I create a process instance using POST runtime/process-instances:
{
'processDefinitionId':'xxxxx',
'variables' : [
{'name' : 'myPath', 'value' : '/tmp/test.txt'}
]
}
And my process definition contains:
<serviceTask id="console" activiti:type="shell" >
<extensionElements>
<activiti:field name="command" stringValue="touch" />
<activiti:field name="arg1" stringValue="${myPath}" />
</extensionElements>
</serviceTask>
The above does not create a file at /tmp/test.txt
But the code bellow does :
<serviceTask id="console" activiti:type="shell" >
<extensionElements>
<activiti:field name="command" stringValue="touch" />
<activiti:field name="arg1" stringValue="/tmp/test.txt" />
</extensionElements>
</serviceTask>
Can anyone tell me how to properly use the variables I sent to the process?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-19-2014 06:22 PM
I havent got the code in front of me, but it might be good to check if the shellTaskActivityBehavior supports expressions, and not just regular strings as fields.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-20-2014 05:17 PM
There was a previous post where this question was asked ands resolved but I fail to understand the answer that was given. Any clarification would be great. here's the link:
http://forums.activiti.org/content/accessing-form-variable-subsequent-shell-task
Thanks in advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2014 05:37 PM
I don't mean to be insistant but this is proving to be a huge sticking point for us. And we're stuck until we find a solution. I would find it odd that a shell Task wouldn't accept expressions (really defeats the purpose) so I'm sure it's just a matter of figuring out how to get the functionality to work.
Like I posted earlier. An explanation was given to the same problem and I just don't know how to interpret it. Where do I put my expression?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2014 08:14 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2014 02:19 AM
<serviceTask id="shellEcho" activiti:type="shell">
<extensionElements>
<activiti:field name="command" stringValue="cmd" />
<activiti:field name="arg1" stringValue="/c" />
<activiti:field name="arg2" stringValue="echo" />
<activiti:field name="arg3" stringValue="EchoTest" />
<activiti:field name="wait" stringValue="true" />
<activiti:field name="outputVariable" stringValue="resultVar"/>
</extensionElements>
</serviceTask>
arg1..3 can be expressions (e.g. use ${varName} )
Regards
Martin
