empty
Section: User Commands (1)
Updated: May, 1 2005
Index
NAME
empty - run processes under pseudo-terminal sessions
SYNOPSIS
empty
-f -i
fifo1
-o
fifo2 command
[command args]
empty
-w [-vn] [-t n] -i
fifo2
-o
fifo1 keyphrase
[response]
empty
-s [-n] -o
fifo1 request
empty
-k
pid
[signal]
DESCRIPTION
empty
is an utility that provides a simple interface to execute and/or interact with processes under pseudo-terminal sessions. This tool is definitely useful in programming of shell scripts which are used to communicate with interactive programs like telnet or ftp. In some cases
empty
can be a substitution for TCL/TK expect or other similar programming tools.
There are several common forms of command lines for
empty.
But the first execution of
empty
is usually a start in the daemon mode to
fork
a new
command
(process) under PTY-session. This can be done with
-f
key.
An interface for the input and output data channels of the forked process is performed by two fifo files which names must be specified with
-i
and
-o
keys. This files are automaticaly created/deleted any time you start/exit
empty
daemon so you must not create them manually.
At this point any application can easily communicate with forked process by writing data to the input fifo and reading answers from the output fifo, see
EXAMPLES
section for the details. To simplify this operations,
empty
offers abilities to just
send
any data (use
-s
key), or even to
watch
the output fifo for the
keyphrase
and reply to the input fifo with
response
(see
-w
key).
Note!
Input fifo for
empty -f ...
is usually an output fifo for
empty -w
and
empty -s
forms. And output fifo of
empty -f ...
is an input fifo for
empty -w ...
If something goes wrong the forked process may be
killed
by the standard kill command, or using
-k
key of
empty.
The following options are available:
- -f
-
fork, spawn, start or execute a new process specified by the
command
and its arguments.
- -s
-
send data to the forked process.
- -w
-
watch
for the
keyphrase
and if specified send the
response
to the input fifo.
If
response
is not set,
empty
waits for the proper
keyphrase
in the output fifo and exits with zero code.
- -k pid
-
send
signal
to the process with
pid.
If
signal
is omitted SIGTERM is used.
- -i fifo1
-
a fifo file, which is used as input for a forked process.
- -o fifo2
-
a fifo file, which is used as output for a forked process.
- -t n
-
Use with
-w
key. Wait for maximum of
n
seconds (default is 10) to receive the
keyphrase.
If
keyphrase
was not recognised, empty exits with -1 code.
- -n
-
remove ending "newline" character when sending data.
- -v
-
kvazi verbose mode. Show all contents of received buffer.
EXAMPLES
- Start a new PTY-session with telnet to localhost:
-
empty -f -i in.fifo -o out.fifo telnet localhost
- Interact with telnet:
-
empty -w -i out.fifo -o in.fifo ogin my_user
empty -w -i out.fifo -o in.fifo assword my_password
- Send commands to telnet with empty:
-
empty -s -o in.fifo who
empty -s -o in.fifo "ls -la /"
- Just cat output from telnet:
-
cat out.fifo
- Send commands to telnet with echo:
-
echo "who am i" > in.fifo
echo "uname -a" > in.fifo
- Kill a process with PID 1234:
-
empty -k 1234
or
kill 1234
RETURN VALUES
If any error occurs
empty
usually exits with code 1 otherwise zero is returned.
AUTHOR
empty
was made by Mikhail E. Zakharov. This software was based on the basic idea of pty version 4.0 Copyright (c) 1992, Daniel J. Bernstein but no code was ported from pty4.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- EXAMPLES
-
- RETURN VALUES
-
- AUTHOR
-
This document was created by
man2html,
using the manual pages.
Time: 13:18:24 GMT, August 13, 2005