How do I send a command after submitting a form?
The Drupal way to do this is to use hook_form_alter() to add a submit hook, and then add your command in the submit hook.  Here's a simple example.
You'll need to add this code to a custom module.
function MYMODULE_form_alter(&amp;$form, FormStateInterface $form_state, $form_id) {
  if ($form_id == 'my_form_id') {
      $form['actions']['submit']['#submit'][] = 'MYMODULE_my_form_submit';
  }
}

function MYMODULE_my_form_submit(array &amp;$form, FormStateInterface &amp;$form_state) {
  // Insert command here.
}