A
Alexander Newald
Hello,
I have a setup (linux) where a program (uml) uses /dev/pts/x as a virtual
console with a login prompt. I now like to use a perl script to interactiv
use this virtual console.
I tried:
#!/usr/bin/perl
open(HANDLE,"/dev/pts/x");
while(<HANDLE>) { print $_; }
close(HANDLE);
print "Read ok\n";
But I noticed that I never will reach the last line "Read ok" because my
script doesn't recognize the end of the /dev/pts/x that sure is right
because it has no real end of file.
After some google work I found IO::Select and ->can_read / ->can_write
#!/usr/bin/perl
use IO::Select
$sel = IO::Select->new();
open(HANDLE,"/dev/pts/x");
$sel->add(\*HANDLE);
while (true) {
while(@ready = $sel->can_read) {
#
# I thought about something like
#
print ">";chomp($tmp = <STDIN>);
print HANDLE "$tmp\n";
#
# But it isn't working
#
}
while(@ready = $sel->can_write) {
#
# What to do here to get the "output" of /dev/pts/x ?
#
}
}
I can see that /dev/pts/x contains some data:
-- snip --
bash> cat /dev/pts/x
Debian GNU/Linux 3.0 vserver tty1
vserver login:
-- snip --
Here is what I want to get: A webpage that will print the output of
/dev/pts/x on a webpage and return the user input to /dev/pts/x to access
the virtual console (/dev/pts/x) from a webpage.
Thanks,
Alexander Newald
I have a setup (linux) where a program (uml) uses /dev/pts/x as a virtual
console with a login prompt. I now like to use a perl script to interactiv
use this virtual console.
I tried:
#!/usr/bin/perl
open(HANDLE,"/dev/pts/x");
while(<HANDLE>) { print $_; }
close(HANDLE);
print "Read ok\n";
But I noticed that I never will reach the last line "Read ok" because my
script doesn't recognize the end of the /dev/pts/x that sure is right
because it has no real end of file.
After some google work I found IO::Select and ->can_read / ->can_write
#!/usr/bin/perl
use IO::Select
$sel = IO::Select->new();
open(HANDLE,"/dev/pts/x");
$sel->add(\*HANDLE);
while (true) {
while(@ready = $sel->can_read) {
#
# I thought about something like
#
print ">";chomp($tmp = <STDIN>);
print HANDLE "$tmp\n";
#
# But it isn't working
#
}
while(@ready = $sel->can_write) {
#
# What to do here to get the "output" of /dev/pts/x ?
#
}
}
I can see that /dev/pts/x contains some data:
-- snip --
bash> cat /dev/pts/x
Debian GNU/Linux 3.0 vserver tty1
vserver login:
-- snip --
Here is what I want to get: A webpage that will print the output of
/dev/pts/x on a webpage and return the user input to /dev/pts/x to access
the virtual console (/dev/pts/x) from a webpage.
Thanks,
Alexander Newald