VTermANSI
Виртуальный терминал (в памяти), поддерживающий ANSI-последовательности. Хранит в памяти содержимое символьного экрана с учётом полученых ANSI-команд, размера терминала и положения курсора. Применятся для протоколов интерактивного взаимодействия с узлом в режиме командной строки (Telnet, SSH, Serial).
Конфигурация
Секция параметров в конфигурации [VTermANSI] .
width
Определяет количество знакомест виртуального терминала.
Значение по умолчанию: 80 Минимальное значание: 80
height
Определяет количество строк виртуального терминала.
Значение по умолчанию: 25 Минимальное значание: 25
timeout
Время ожидания операции в секундах. Может принимать не целые значения, например, 0.01.
Значение по умолчанию: 1
streamtimeout
Время ожидяния окончания потока данных. Считается от последнего полученного набора данных. То есть, если после получения блока данных в течении указанного времени не поступило новых данных, то операция чтения завершается. Применяется для чтения, когда не определен признак окончания потока данных, или применение timeout может вызывать лишнее ожидание после окончания блока данных, либо при большом объеме, прерывание чтения.
Значение по умолчанию: 0.1
Команды
docmdrecv <комбинация_символов>
Устанавливает завершающую комбинацию конца строки при получении данных. В разных системах окончания строк отличаются. Обычно это "n" (Line Feed) или "r" (Carriage Return) , либо их сочетание "nr" (LFCR) или "rn" (CRLF).
Параметры:
<комбинация_символов> - последовательность символов.
Пример.
docmdsend <комбинация_символов>
Устанавливает завершающую комбинацию конца строки при отправке команды.
Параметры:
<комбинация_символов> - последовательность символов.
Пример.
prompt <строка_приглашения>
Установить последовательность, обозначающую строку приглашения к вводу команды. Служит для определения завершения выполнения команд.
Параметры:
<строка_приглашения> - строка приглашения для текущего узла и протокола.
Пример.
Результат:
Screen:
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Fri Aug 15 01:38:29 2025 from 192.0.2.1
user@localhost:~$
user@localhost:~$
user@localhost:~$ python3
Python 3.11.2 (main, Nov 30 2024, 21:22:50) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 1+2+3
6
>>>
>>>
>>> print ("Something remote")
Something remote
>>>
>>>
>>>
user@localhost:~$ dat
-bash: dat: команда не найдена
user@localhost:~$
user@localhost:~$
user@localhost:~$ date
Пт 15 авг 2025 01:38:30 +11
user@localhost:~$
vtIA <ожидаемая_строка> <отправляемая_строка> ...
Выполнить последовательность ожидаемых и отправлемых строк. Нечётная позиция - ожидаемая строка, чётная - данные для отправки. Пустое значение обозначается "" и не ожидает/отправляет данные.
Параметры:
<ожидаемая_строка> - читает данные по текущему канал до обнаружения ожидаемой строки.
<отправляемая_строка> - отправляет указаннаые данные по текущему каналу.
Пример.
Результат:
==============
cat /var/log/messages | tail -4
Jun 19 17:42:41 login[2467]: user login on 'pts/0'
Jun 19 17:49:01 login[2495]: user login on 'pts/1'
Jun 19 17:50:05 login[2501]: user login on 'pts/1'
Jun 19 17:52:10 login[2507]: user login on 'pts/1'
user@192.0.2.2:~$
==============
vtPut <отправляемая_строка>
Отправить строку даннных по текущему каналу. При выполнении этой команды не происходит чтения результата, ожидания контрольной последовательности или строки приглашения, не добавляются символы конца строки/команды.
Параметры:
<отправляемая_строка> - отправляет указаннаые данные по текущему каналу.
Пример.
Результат:
=== Stream readed: =============================================================
ls /dev/
Display all 187 possibilities? (y or n)
=== TERMINAL DUMP ==============================================================
Linux dhome05 6.1.0-29-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.123-1 (2025-01-02
) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Aug 18 00:54:17 2025 from 192.0.2.1
denis@dhome05:~$ ls /dev/
Display all 187 possibilities? (y or n)
================================================================================
=== Stream readed: =============================================================
autofs parport0 tty25 ttyS1
block/ port tty26 ttyS2
bsg/ ppp tty27 ttyS3
btrfs-control psaux tty28 uhid
bus/ ptmx tty29 uinput
char/ pts/ tty3 urandom
console random tty30 userfaultfd
core rfkill tty31 vboxdrv
cpu/ rtc tty32 vboxdrvu
cpu_dma_latency rtc0 tty33 vboxnetctl
cuse sda tty34 vboxusb/
disk/ sda1 tty35 vcs
dri/ sda2 tty36 vcs1
drm_dp_aux0 sda4 tty37 vcs12
fb0 sda5 tty38 vcs2
fd/ sda6 tty39 vcs3
full sdb tty4 vcs4
fuse sdb1 tty40 vcs5
hidraw0 sdb2 tty41 vcs6
hidraw1 sdb5 tty42 vcs7
hidraw2 sg0 tty43 vcsa
hpet sg1 tty44 vcsa1
hugepages/ shm/ tty45 vcsa12
hwrng snapshot tty46 vcsa2
--More--
=== TERMINAL DUMP ==============================================================
autofs parport0 tty25 ttyS1
block/ port tty26 ttyS2
bsg/ ppp tty27 ttyS3
btrfs-control psaux tty28 uhid
bus/ ptmx tty29 uinput
char/ pts/ tty3 urandom
console random tty30 userfaultfd
core rfkill tty31 vboxdrv
cpu/ rtc tty32 vboxdrvu
cpu_dma_latency rtc0 tty33 vboxnetctl
cuse sda tty34 vboxusb/
disk/ sda1 tty35 vcs
dri/ sda2 tty36 vcs1
drm_dp_aux0 sda4 tty37 vcs12
fb0 sda5 tty38 vcs2
fd/ sda6 tty39 vcs3
full sdb tty4 vcs4
fuse sdb1 tty40 vcs5
hidraw0 sdb2 tty41 vcs6
hidraw1 sdb5 tty42 vcs7
hidraw2 sg0 tty43 vcsa
hpet sg1 tty44 vcsa1
hugepages/ shm/ tty45 vcsa12
hwrng snapshot tty46 vcsa2
--More--
================================================================================
vtSize <ширина> <высота>
Установить размер виртуального терминала. Минимальный размер 80x25 знакомест.
Параметры:
<ширина> - ширина виртуального терминала.
<высота> - высота виртуального терминала.
Пример.
Результат:
TERMINAL SIZE 80x25
btrfs-control loop0 sda tty16 tty40 tty8 vcsa3
bus loop1 sda1 tty17 tty41 tty9 vcsa4
char loop2 sda2 tty18 tty42 ttyS0 vcsa5
console loop3 sda4 tty19 tty43 ttyS1 vcsa6
core loop4 sda5 tty2 tty44 ttyS2 vcsa7
cpu loop5 sda6 tty20 tty45 ttyS3 vcsu
cpu_dma_latency loop6 sdb tty21 tty46 uhid vcsu1
cuse loop7 sdb1 tty22 tty47 uinput vcsu12
disk loop-control sdb2 tty23 tty48 urandom vcsu2
dri lp0 sdb5 tty24 tty49 userfaultfd vcsu3
drm_dp_aux0 mapper sg0 tty25 tty5 vboxdrv vcsu4
fb0 mei0 sg1 tty26 tty50 vboxdrvu vcsu5
fd mem shm tty27 tty51 vboxnetctl vcsu6
full mqueue snapshot tty28 tty52 vboxusb vcsu7
fuse net snd tty29 tty53 vcs vfio
hidraw0 null stderr tty3 tty54 vcs1 vga_arbiter
hidraw1 nvram stdin tty30 tty55 vcs12 vhci
hidraw2 parport0 stdout tty31 tty56 vcs2 vhost-net
hpet port tty tty32 tty57 vcs3 vhost-vsock
hugepages ppp tty0 tty33 tty58 vcs4 watchdog
hwrng psaux tty1 tty34 tty59 vcs5 watchdog0
initctl ptmx tty10 tty35 tty6 vcs6 zero
input pts tty11 tty36 tty60 vcs7
kfd random tty12 tty37 tty61 vcsa
denis@dhome05:~$
================================================================
TERMINAL SIZE 120x40
user@localhost:~$ ls /dev
autofs fuse loop4 ptmx sg1 tty17 tty32 tty48 tty63 vcs1 vcsu
block hidraw0 loop5 pts shm tty18 tty33 tty49 tty7 vcs12 vcsu1
bsg hidraw1 loop6 random snapshot tty19 tty34 tty5 tty8 vcs2 vcsu12
btrfs-control hidraw2 loop7 rfkill snd tty2 tty35 tty50 tty9 vcs3 vcsu2
bus hpet loop-control rtc stderr tty20 tty36 tty51 ttyS0 vcs4 vcsu3
char hugepages lp0 rtc0 stdin tty21 tty37 tty52 ttyS1 vcs5 vcsu4
console hwrng mapper sda stdout tty22 tty38 tty53 ttyS2 vcs6 vcsu5
core initctl mei0 sda1 tty tty23 tty39 tty54 ttyS3 vcs7 vcsu6
cpu input mem sda2 tty0 tty24 tty4 tty55 uhid vcsa vcsu7
cpu_dma_latency kfd mqueue sda4 tty1 tty25 tty40 tty56 uinput vcsa1 vfio
cuse kmsg net sda5 tty10 tty26 tty41 tty57 urandom vcsa12 vga_arbiter
disk kvm null sda6 tty11 tty27 tty42 tty58 userfaultfd vcsa2 vhci
dri log nvram sdb tty12 tty28 tty43 tty59 vboxdrv vcsa3 vhost-net
drm_dp_aux0 loop0 parport0 sdb1 tty13 tty29 tty44 tty6 vboxdrvu vcsa4 vhost-vsock
fb0 loop1 port sdb2 tty14 tty3 tty45 tty60 vboxnetctl vcsa5 watchdog
fd loop2 ppp sdb5 tty15 tty30 tty46 tty61 vboxusb vcsa6 watchdog0
full loop3 psaux sg0 tty16 tty31 tty47 tty62 vcs vcsa7 zero
user@localhost:~$
================================================================
Функции
doCmd(<команда>,<время ожидания>)
Отправлет команду по текущему каналу, завершая установленной последовательностью docmdsend. Считывает входящие данные до обнаружения строки приглашения в течении установленного времени ожидания.
Параметры:
<команда> - команда, отправляемая в текущий канал.
<время ожидания> - не обязательный параметр в секундах. Если не указан, используется время ожидания текущего канала.
Возвращаемое значение:
Строка, содержащая вывод - результат выполнения команды
Пример.
Результат:
Result:
UPTIME(1) User Commands UPTIME(1)
NAME
uptime - Tell how long the system has been running.
SYNOPSIS
uptime [options]
DESCRIPTION
uptime gives a one line display of the following information. The current time, how long
the system has been running, how many users are currently logged on, and the system load
averages for the past 1, 5, and 15 minutes.
This is the same information contained in the header line displayed by w(1).
System load averages is the average number of processes that are either in a runnable or
uninterruptable state. A process in a runnable state is either using the CPU or waiting
to use the CPU. A process in uninterruptable state is waiting for some I/O access, eg
waiting for disk. The averages are taken over the three time intervals. Load averages
are not normalized for the number of CPUs in a system, so a load average of 1 means a sin‐
gle CPU system is loaded all the time while on a 4 CPU system it means it was idle 75% of
the time.
OPTIONS
-p, --pretty
show uptime in pretty format
-h, --help
display this help text
-s, --since
system up since, in yyyy-mm-dd HH:MM:SS format
-V, --version
display version information and exit
FILES
/var/run/utmp
information about who is currently logged on
/proc process information
AUTHORS
uptime was written by Larry Greenfield ⟨greenfie@gauss.rutgers.edu⟩ and Michael K. Johnson
⟨johnsonm@sunsite.unc.edu⟩
SEE ALSO
ps(1), top(1), utmp(5), w(1)
REPORTING BUGS
Please send bug reports to ⟨procps@freelists.org⟩
procps-ng December 2012 UPTIME(1)
vthead()
Возвращает строку данных, полученную после подключения к узлу до отправки каких-либо команд. Обычно эти данные содержат заставку/приветствие/первичную информацию/лицензионные условия и строку приглашения в конце.
Параметры:
Нет.
Возвращаемое значение:
Строка, содержащая вывод после подключения.
Пример.
Результат:
Linux localhost 6.1.0-29-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.123-1 (2025-01-02) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Wed Aug 20 02:37:31 2025 from 192.0.2.1
denis@dhome05:~$
vtDump()
Возвращает строку - текущий снимок терминала, только символьные данные.
Параметры:
Нет.
Возвращаемое значение:
Строка - снимок экрана без ANSI-последовательностей.
vtDumpANSI()
Возвращает строку - текущий снимок терминала, включая ANSI-последовательности (цветовык атрибуты).
Параметры:
Нет.
Возвращаемое значение:
Строка - снимок экрана.
vtReadUntil(<строка>,<время_ожидания>)
Читает данные пока не встретит указанную последовательность или не выйдет время ожидания.
Параметры:
<строка> - ожидаемая последовательность получаемых данных.
<время_ожидания> - время ожидания последовательности. Неообязательный параметр.
Возвращаемое значение:
<строка> - полученные данные, включая ожидаемую последоватльность.
Пример.
man -P '' w > /tmp/w.txt; cat /tmp/w.txt
W(1) User Commands W(1)
NAME
w - Show who is logged on and what they are doing.
SYNOPSIS
w [options] [user]
DESCRIPTION
w displays information about the users currently on the machine, and
their processes. The header shows, in this order, the current time,
how long the system has been running, how many users are currently
logged on, and the system load averages for the past 1, 5, and 15 min‐
utes.
The following entries are displayed for each user: login name, the tty
name, the remote host, login time, idle time, JCPU, PCPU, and the com‐
mand line of their current process.
The JCPU time is the time used by all processes attached to the tty.
It does not include past background jobs, but does include currently
running background jobs.
The PCPU time is the time used by the current process, named in the
"what" field.
COMMAND-LINE OPTIONS
vtStreamRead(<время_ожидания>)
Читает данные, пока идет поток данных. Окончанием потока считается исход времени ожидания после последнего блока данных. Для каналов с большой задержкой или большим количеством потерь необходимо увеличить время ожидания.
Параметры:
<время_ожидания> - время ожидания. Неообязательный параметр.
Возвращаемое значение:
<строка> - прочитанные данные..