NAME
IO::Pty - Pseudo TTY object class
VERSION
0.92_03 beta
SYNOPSIS
use IO::Pty;
$pty = new IO::Pty;
$slave = $pty->slave;
foreach $val (1..10) {
print $pty "$val\n";
$_ = <$slave>;
print "$_";
}
close($slave);
# spawn a program
$cmd = IO::Pty->spawn($command, @args)
or die "Cannot spawn $command: $!\n";
print $cmd "command\n";
$response = <$cmd>;
kill TERM => $cmd->slave_pid;
DESCRIPTION
IO::Pty
provides an interface to allow the creation of a pseudo tty.
IO::Pty
inherits from IO::Handle
and so provide all the methods defined by the IO::Handle
package.
Please note that pty creation is very system-dependend. If you have problems, see IO::Tty for help.
CONSTRUCTOR
- new
-
The
new
constructor takes no arguments and returns a new file object which is the master side of the pseudo tty.
METHODS
- slave
-
The
slave
method will return a newIO::Pty
object which represents the slave side of the pseudo tty. If IO::Stty is installed, you can call $slave->stty() to modify the terminal settings. - ttyname
-
Returns the name of the pseudo tty. On UNIX machines this will be the pathname of the device.
- spawn
-
Spawns the given command via exec() (see there for semantics) and attaches its stdin/out/err to the slave side of the pty. Returns the master pty upon success or undef upon failure; $! will contain the error of the failed exec().
spawn() autovivifies a pty if called without an object, i.e.
spawn IO::Pty (@command);
or
IO::Pty->spawn(@command);
- slave_pid
-
Returns the PID of the spawned process (if any).
SEE ALSO
MAILING LISTS
As this module is mainly used by Expect, support for it is available via the two Expect mailing lists, expectperl-announce and expectperl-discuss, at
http://lists.sourceforge.net/lists/listinfo/expectperl-announce
and
http://lists.sourceforge.net/lists/listinfo/expectperl-discuss
AUTHORS
Originally by Graham Barr <gbarr@pobox.com>, based on the Ptty module by Nick Ing-Simmons <nik@tiuk.ti.com>.
Now maintained and heavily rewritten by Roland Giersig <RGiersig@cpan.org>.
The spawn() code was modeled after its Tcl/Expect counterpart by Don Libes <libes@nist.gov>.
Contains copyrighted stuff from openssh v3.0p1, authored by Tatu Ylonen <ylo@cs.hut.fi>, Markus Friedl and Todd C. Miller <Todd.Miller@courtesan.com>.
COPYRIGHT
Now all code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Nevertheless the above AUTHORS retain their copyrights to the various parts and want to receive credit if their source code is used. See the source for details.
DISCLAIMER
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.