#!/usr/bin/perl use IO::Socket; $SIG{CHLD} = sub {wait ()}; $main_sock = new IO::Socket::INET (LocalHost => '0.0.0.0', LocalPort => 1200, Listen => 5, Proto => 'tcp', Reuse => 1, ); while ($new_sock = $main_sock->accept()) { $pid = fork(); if ($pid == 0) { # Child process while (defined ($buf = <$new_sock>)) { print $new_sock `$buf`; } exit(0); } } close ($main_sock);
The above works functionally, but when I telnet from windows and run command ls, the output is a mess:
..
plit
str
strref
swig.txt
system
tax.perl
test.gif
test_graph
test.txt
time
tk
tmp
tty
typeglo
b
url
use
vt100
..
The above is what I get after run the command ls.
Seems windows prompt can't display vt100 correctly, how to fix this issue?
In reply to Have trouble implementing a shell-alike script by PerlOnTheWay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |