title: WildFly CLI run script against embedded server
body: <p>I have some scripts that I run using <code>jboss-cli -c --controller=... --file=myscript.cli</code>.
  The <code>-c</code> and <code>--controller</code> options are great, because my script does not know which server it should be run against and can be reused for multiple servers.</p>
  
  <p>I now want to use the <a href="https://wildfly.org/news/2015/03/13/Offline-CLI/" rel="nofollow noreferrer">offline-cli</a> feature to avoid port conflicts and prevent servers from beeing reachable through the network while they are beeing set up.
  My issue is now that in order to start an embedded server I have to use the CLI-command <code>embed-server</code>, but I don't want to add that command to my scripts, because the scripts are not supposed to know the name of the server config xml file.</p>
  
  <p>Unfortunately I can't use both <code>--command="embed-server --server-config=my-standalone.xml"</code> and <code>--file=myscript.cli</code> at the same time, because the CLI complains with:</p>
  
  <pre><code>Only one of '--file', '--commands' or '--command' can appear as the argument at a time.
  </code></pre>
  
  <p>Another thing I tried was: <code>--commands="embed-server --server-config=my-standalone.xml,run-batch --file=\"myscript.cli\"</code> but this does not work either, because my scripts contain some if-else logic, for instance:</p>
  
  <pre><code>if (outcome == success) of /subsystem=iiop-openjdk:read-resource()
    /subsystem=iiop-openjdk:remove()
  end-if
  </code></pre>
  
  <p>And unfortunately conditional logic is not supported in batch mode (see <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1083176" rel="nofollow noreferrer">https://bugzilla.redhat.com/show_bug.cgi?id=1083176</a>).</p>