LINUX.ORG.RU

bashible execute raw bash command

 


0

1

есть https://github.com/mig1984/bashible он позволяет выполнять типа

@ Synchronizing files
  - result synced rsync -av /foo /bar

вот ее функция

result() {
  local name=$1; shift
  ble_check_cmd "$1"
  local old=${_BLE_SUPPRESS_ERRORS}
  export _BLE_SUPPRESS_ERRORS=1
  local ex=0
  "$@" || ble_handle_exitstatus $? "$@" || ex=$?
  export _BLE_SUPPRESS_ERRORS=$old
  eval "
    $name() {
      if test \$# -gt 0; then
        test \"$ex\" \"\$@\"; # with arguments - to test exitcode
      else
        return \"$ex\"        # without - to test boolean
      fi
    }
  "
  return 0
}

А вот как выполнить что-то типа:

if lsmod | grep pcspkr &> /dev/null ; then
  rmmod pcspkr
fi

т.е raw bash command



Последнее исправление: Xwo (всего исправлений: 4)

А ты их документацию не пробовал читать? Там немного. Ссылка прямо из README.md:
Functions / core functions / evaluate

ABW ★★★★★
()
Ответ на: комментарий от ABW
- evaluate "if [[ -d /var/cache/apt/archives ]]; then cp -prf /var/cache/apt/archives/* /home/user/archives 2>/dev/null; fi"

out


 system.yaml  command 'evaluate if [[ -d /var/cache/apt/archives ]]; then cp -prf /var/cache/apt/archives/* /home/user/archives 2>/dev/null; fi' failed with exit code 1 (CWD is /home/user/media/source_code/bashible/hosts/desktop/services)
Xwo
() автор топика
Ответ на: комментарий от Xwo
- evaluate 'if test -d /var/cache/apt/archives; then mkdir /home/user/archives1 2>/dev/null; fi'

out:

/home/user/media/source_code/bashible/hosts/desktop/services/system.yaml: line 13: syntax error near unexpected token `then'
 system.yaml  command 'evaluate if test -d /var/cache/apt/archives; then mkdir /home/user/archives1 2>/dev/null; fi' failed with exit code 1 (CWD is /home/user/media/source_code/bashible/hosts/desktop/services)
Xwo
() автор топика
Последнее исправление: Xwo (всего исправлений: 1)
VAR='[[ -d /var/cache/apt/archives ]]'
- evaluate 'if eval "${VAR}"; then mkdir /home/user/archives1; fi'

Разтудыт твойу туды

Xwo
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.