Skip to content

text_slave en

Hamatoma edited this page Aug 7, 2022 · 1 revision

Objective

The command line program text_slave "understands" the same commands as the GUI program text_butler. It is used for automation using created scripts.

Application

There are three ways to start text_slave:

text_slave --help
# writes a help text to stdout (into the terminal).
text_slave
# reads the commands from stdin and writes the "output" buffer to stdout after executing the commands.
text_slave FILE
# reads the commands from the file "FILE" and writes the buffer "output" to stdout after executing the commands.

Example

We use the "read from stdin" type:

text_slave <<'EOS'
# load the settings into buffer "data":
load file="/etc/php/7.3/php.ini" output=data
# load the search expression of the interesting settings into buffer "regexpr":
copy text="^(memory_limit|upload_max_filesize|max_file_uploads|post_max_size|"
copy text="max_execution_time|max_input_time|default_socket_timeout)" output=regexpr append
copy text=i~"== previous values~n"
# log the current data of some variables (settings):
filter input=data append filter=i~"~[regexpr]"
# replace some settings:
replace input=data output=data What=;r/^(memory_limit\s*=\s*).*$/;"%group1%2048M"
replace input=data output=data What=;r/^(upload_max_filesize\s*=\s*).*$/;"%group1%512M"
replace input=data output=data What=;r/^(max_file_uploads\s*=\s*).*$/;"%group1%100"
replace input=data output=data What=;r/^(max_execution_time\s*=\s*).*$/;"%group1%600"
replace input=data output=data What=;/^(max_input_time\s*=\s*).*$/;"%group1%600"
replace input=data output=data What=;r/^(default_socket_timeout\s*=\s*).*$/;"%group1%600"
copy text=i~"~n== current values~n" output=mylog append
# log the current settings:
filter input=data append filter=ri~"~[regexpr]"
store file="/etc/php/7.3/php.ini" input=data
EOS
Note: The data collected in the "output" buffer is automatically saved after executing the commands output to stdout (i.e. to the terminal).

Clone this wiki locally