-
1. Re: Can I write CLI to create datasource if not defined?
ssilvert Jan 10, 2013 3:01 PM (in response to sboscarine)1 of 1 people found this helpfulSome combination of these should get you where you want to go:
Advanced CLI scripting with Groovy, Rhino, Jython, etc.
Using the CLI remote client jar
The key is using the remote client jar from AS7.2. It works with EAP 6.0.1, so you get all the new goodies.
Stan
-
2. Re: Can I write CLI to create datasource if not defined?
sboscarine Jan 21, 2013 4:10 PM (in response to ssilvert)Following the example from https://community.jboss.org/wiki/If-elseControlFlow, in EAP 6.0.1, when I save the following to a file named undeploy.cli...
if (outcome != success) of /deployment=mywar.war:read-resource deploy mywar.war end-if
...and run, I get:
C:\Users\sboscarine\workspace\sl-ear-ee6>jboss-cli.bat -c --file=undeploy.cli Unexpected command 'if (outcome != success) of /deployment=mywar.war:read-resource'. Type 'help --commands' for the list of supported commands.
Both the read-resource and deploy commands work in isolation. Am I doing something wrong?
-
3. Re: Can I write CLI to create datasource if not defined?
nickarls Jan 21, 2013 5:08 PM (in response to sboscarine)Did you really use the 7.2 remote client?
-
4. Re: Can I write CLI to create datasource if not defined?
sboscarine Jan 21, 2013 5:17 PM (in response to nickarls)Yes. I am using both the client and server from EAP 6.0.1:
C:\Users\sboscarine\workspace\sl-ear-ee6>jboss-cli.bat -c [standalone@localhost:9999 /] version JBoss Admin Command-line Interface JBOSS_HOME: C:\tools\jboss-eap-6.0 JBoss AS release: 7.1.3.Final-redhat-4 "Arges" JBoss AS product: EAP 6.0.1.GA JAVA_HOME: C:\Program Files\Java\jdk1.7.0_03 java.version: 1.7.0_03 java.vm.vendor: Oracle Corporation java.vm.version: 22.1-b02 os.name: Windows 7 os.version: 6.1
(the server and client are on the same machine. I am using jboss-cli.bat in the same folder I am launching standalone.bat from)
Nicklas Karlsson wrote:
Did you really use the 7.2 remote client?
-
5. Re: Can I write CLI to create datasource if not defined?
nickarls Jan 22, 2013 1:40 AM (in response to sboscarine)I pasted in the
if (result.value == true) of /system-property=test:read-resource
/system-property=test:write-attribute(name=value,value=false)
else
/system-property=test:write-attribute(name=value,value=true)
end-ifexample into the console of a 7.2-SNAP and it worked (after I added the property) fine
-
6. Re: Can I write CLI to create datasource if not defined?
sboscarine Jan 30, 2013 2:59 PM (in response to nickarls)Sorry for the delay in getting back. I tried your snippet as well. I get Unexpected command 'if (result.value == true) of /system-property=test:read-resource'.
I must be doing something silly wrong. Any leads?
C:\Users\sboscarine\workspace\axeda-console>cat test.cli if (result.value == true) of /system-property=test:read-resource /system-property=test:write-attribute(name=value,value=false) else /system-property=test:write-attribute(name=value,value=true) end-if C:\Users\sboscarine\workspace\axeda-console>jboss-cli -c --file=test.cli Unexpected command 'if (result.value == true) of /system-property=test:read-resource'. Type 'help --commands' for the list of supported commands. C:\Users\sboscarine\workspace\axeda-console>jboss-cli -c --commands="version" JBoss Admin Command-line Interface JBOSS_HOME: C:\tools\jboss-eap-6.0 JBoss AS release: 7.1.3.Final-redhat-4 "Arges" JBoss AS product: EAP 6.0.1.GA JAVA_HOME: C:\Program Files\Java\jdk1.7.0_11 java.version: 1.7.0_11 java.vm.vendor: Oracle Corporation java.vm.version: 23.6-b04 os.name: Windows 7 os.version: 6.1
-
7. Re: Can I write CLI to create datasource if not defined?
nickarls Jan 31, 2013 1:50 AM (in response to sboscarine)If you are running everything from the bin directory of a 7.1.3 then you're not using the 7.2 client ;-)
-
8. Re: Can I write CLI to create datasource if not defined?
bmaxwell Jul 3, 2013 11:03 PM (in response to sboscarine)EAP 6.1 is based on AS 7.2, EAP 6.0.1 is AS 7.1.3 and does not have if/then/else
-
9. Re: Can I write CLI to create datasource if not defined?
radcortez Dec 30, 2013 1:57 PM (in response to sboscarine)Hey Steven,
I'm also trying to do the same. Any luck?
It seems that the add module command is always executed even if it's inside an if-else CLI control flow.