added tips to lamer.bash help
[mirrors/Programs.git] / php / telnet
... / ...
CommitLineData
1#!/usr/bin/php
2<?php
3
4$usage = "telnet host [port]\n";
5if($argc > 1) $host = $argv[1]; else die($usage);
6$port = 23; if($argc > 2) $port = $argv[2];
7if($argc > 3) die($usage);
8
9echo("Connecting to $host:$port...\n");
10$sock = pfsockopen($host, $port);
11if($sock) echo("Connected!\n\n"); else die("Failed!\n");
12$stdin = fopen('php://stdin', 'r');
13stream_set_blocking($sock, 0);
14stream_set_blocking($stdin, 0);
15
16while(!feof($sock) && !feof($stdin)) {
17 echo(fgetc($sock));
18 fwrite($sock, fgetc($stdin));
19}
This page took 0.53366 seconds and 4 git commands to generate.