Here's the complete example of the script:
#!/usr/bin/perl
use strict;
use warnings;
use IO::Pty::Easy;
# Get stdin when this char is found (Telnet).
$/ = "\n";
# Autoflush, write without buffering (Telnet).
$| = 1;
# Main loop.
undef $_;
my $quit = 0;
my $input;
my $pty = IO::Pty::Easy->new();
do {
$input = <STDIN>;
# Remove trailing new line character.
$input =~ s/\r//g;
$input =~ s/\n//g;
eval {
if ($input =~ /quit/) {
$quit = 1;
}
elsif ($input =~ /run/) {
my $st = $pty->spawn("/usr/bin/omshell");
die "Cannot run /usr/bin/omshell" unless ($st);
}
else {
reply(help());
}
};
reply($@) if ($@);
print "> ";
} while (!$quit);
sub help {
#---------------------------------------------------------------------
+---------|
return qq{
quit
run
Launch app over IO::Pty::Easy.
};
}
# Reply to user.
sub reply {
print shift, "\n";
}
If you run that with xinetd you will find out that subprocess cannot be launched. |