Highlighted
Outstanding Contributor.
Outstanding Contributor.
663 views

how to pass command arguments with spaces in counteract?

Hi,

I'm trying to pass command arguments to a script with the counteract connector.

Manually invoking the script works just fine:

arcsight@esm:~/scripts#./counteract_test.sh --arg1='test argument 1' --arg2='1 2 3 4' --arg3="test argument 3"
 
Output:
Testing arguments passing
--arg1 value is: test argument 1
--arg2 value is: 1 2 3 4
--arg3 value is: test argument 3
 
But when testing with counteract and putting single quotes around the variables it inserts the quotes and when a space in the value it breaks
 
Testing to pass with counteract:
 
command[0].name=counteract_TEST
command[0].displayname="Test CounterACT”
 
command[0].parameter.count=3
command[0].parameter[0].name=arg1
command[0].parameter[0].displayname="arg1"
command[0].parameter[1].name=arg2
command[0].parameter[1].displayname="arg2"
command[0].parameter[2].name=arg3
command[0].parameter[2].displayname=“arg3”
 
command[0].action=/home/arcsight/scripts/counteract_test.sh --arg1='${arg1}' --arg2='${arg2}' --arg3='${arg3}'
 
First without spaces (works)
test_counteract.png
 
test_counteract1.png
Counteract inserted the single qoutes literally...
 
And when putting spaces the variable is broken at the first space seen.
 
Does anyone know how to pass variables with spaces in counteract command actions??
/steven
0 Likes
2 Replies
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Hi

 

This is an example that always worked for me

I guess the difference is I marked all of the arguments withing the ""

command[0].action=D:\\folder\\file.exe "ImageLocation:${Icon}^MailSubject:${MailSubject}^SendMailTo:${SendMailTo}^ArcSightFields:${ArcSightFields}^ArcSightValues:${ArcSightValues}"

command[0].action=D:\\folder\\file.exe "ImageLocation:${Icon}^MailSubject:${MailSubject}^SendMailTo:${SendMailTo}^ArcSightFields:${ArcSightFields}^ArcSightValues:${ArcSightValues}"

 

Best regards

David

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Ok thx David, I have thought of that solution to concat everything in a single string with separators and in the script split all the parameters back to arguments.

so something like this:

command[0].action=/scripts/script.sh "--param1='bla bla bla',--param2='bla bla bla',--param3='bla bla bla'"

I'll come back here to post the final solution if I have figured it out script-wise

P.S. I wish there was some more development on this connector like the ability to have dropdowns for choosing fixed values in a couteract command

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.