By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,889 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,889 IT Pros & Developers. It's quick & easy.

How to send <ESC> to a telnet server??

P: n/a
Hi

I have been getting statistical rapports from a machine via a
telnet server. Until now it has been done manually. However
I want to automate the proccess, and scedule a PHP script to
run everyday.

Using my terminal, I give the command to order a rapport,
and then press <ESC>. Then the rapport is printed out.

Using a PHP script I can order a rapport, all works fine,
except I can not get the printout. When I try to send <ESC>
the telnet server responds with "syntax fault" so
I'm not doing it right.

I have tried the following:

$do_esc=chr(27);
fputs ($fp, "$do_esc");

and

fputs ($fp, "\e");

Any ideas???

<?php
$address = '100.100.1.5024';
$port = 5000;
$fp = fsockopen($address,$port);
$s='o';
$s=fgets($fp,128); //the telnet server responds when connected
echo("<br>$s<br>");

fputs ($fp, "SOME-COMMAND"); //some command to order a rapport
$s=fgets($fp,128);
echo("<br>$s<br>"); //telnet server responds with "rapport failed" or "executed"

/*
Here the tricky part starts,
trying to get the rapport
printed out. No success so far.
To get the rapport printed out
<ESC> has to sent to the telnet
server
*/

$do_esc=chr(27);
fputs ($fp, "$do_esc"); //this does not work, trying to
//send <ESC> to the telnet server.

while (!strstr($t,'END')) { // supposed to get the printout
$t=fgets ($fp,128); // that never comes
echo("<br>$t");
}
fclose($fp);
?>
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 8 Jun 2004 04:51:44 -0700, gu****@visir.is (G520) wrote:
Hi

I have been getting statistical rapports from a machine via a
telnet server. Until now it has been done manually. However
I want to automate the proccess, and scedule a PHP script to
run everyday.

Using my terminal, I give the command to order a rapport,
and then press <ESC>. Then the rapport is printed out.

Using a PHP script I can order a rapport, all works fine,
except I can not get the printout. When I try to send <ESC>
the telnet server responds with "syntax fault" so
I'm not doing it right.

I have tried the following:

$do_esc=chr(27);
fputs ($fp, "$do_esc");

and

fputs ($fp, "\e");

Any ideas???

<?php
$address = '100.100.1.5024';
$port = 5000;
$fp = fsockopen($address,$port);
$s='o';
$s=fgets($fp,128); //the telnet server responds when connected
echo("<br>$s<br>");

fputs ($fp, "SOME-COMMAND"); //some command to order a rapport
$s=fgets($fp,128);
echo("<br>$s<br>"); //telnet server responds with "rapport failed" or "executed"

/*
Here the tricky part starts,
trying to get the rapport
printed out. No success so far.
To get the rapport printed out
<ESC> has to sent to the telnet
server
*/

$do_esc=chr(27);
fputs ($fp, "$do_esc"); //this does not work, trying to
//send <ESC> to the telnet server.

while (!strstr($t,'END')) { // supposed to get the printout
$t=fgets ($fp,128); // that never comes
echo("<br>$t");
}
fclose($fp);
?>


define('ESCAPE', 0x1B);
fputs($fp, ESCAPE . "\n"); // probably needs the \n for the recieving end to process the data.
fflush($fp); // make sure the data is sent to the recieving end now...

Jul 17 '05 #2

P: n/a

"G520" <gu****@visir.is> wrote in message
news:51**************************@posting.google.c om...
Hi

I have been getting statistical rapports from a machine via a
telnet server. Until now it has been done manually. However
I want to automate the proccess, and scedule a PHP script to
run everyday.

Using my terminal, I give the command to order a rapport,
and then press <ESC>. Then the rapport is printed out.

Using a PHP script I can order a rapport, all works fine,
except I can not get the printout. When I try to send <ESC>
the telnet server responds with "syntax fault" so
I'm not doing it right.

I have tried the following:

$do_esc=chr(27);
fputs ($fp, "$do_esc");

and

fputs ($fp, "\e");

Any ideas???

<?php
$address = '100.100.1.5024';
$port = 5000;
$fp = fsockopen($address,$port);
$s='o';
$s=fgets($fp,128); //the telnet server responds when connected
echo("<br>$s<br>");

fputs ($fp, "SOME-COMMAND"); //some command to order a rapport
$s=fgets($fp,128);
echo("<br>$s<br>"); //telnet server responds with "rapport failed" or "executed"
/*
Here the tricky part starts,
trying to get the rapport
printed out. No success so far.
To get the rapport printed out
<ESC> has to sent to the telnet
server
*/

$do_esc=chr(27);
fputs ($fp, "$do_esc"); //this does not work, trying to
//send <ESC> to the telnet server.

while (!strstr($t,'END')) { // supposed to get the printout
$t=fgets ($fp,128); // that never comes
echo("<br>$t");
}
fclose($fp);
?>


Telnet escape is actually ^] . Try that.
Jul 17 '05 #3

P: n/a
Thanks guys, but I am:

WRONG – WRONG – WRONG !!!!!!!!

My terminal program translates <ESC> to <CTR>+d

So I need a way to send <CTR>+d and not <ESC> to the telnet server.

Anyone know how I can do this????
Jul 17 '05 #4

P: n/a
G520 wrote:
Thanks guys, but I am:

WRONG - WRONG - WRONG !!!!!!!!

My terminal program translates <ESC> to <CTR>+d

So I need a way to send <CTR>+d and not <ESC> to the telnet server.

Anyone know how I can do this????


$ctrld=chr(4);
fwrite ($fp, $ctrld,1);

--
MVH Jeppe Uhd - NX http://nx.dk
Webhosting for nørder og andet godtfolk
Jul 17 '05 #5

P: n/a
"Jeppe Uhd" <kn*********@nx.dk> wrote in message news:<m2*************@crm.nwg.dk>...
G520 wrote:
Thanks guys, but I am:

WRONG - WRONG - WRONG !!!!!!!!

My terminal program translates <ESC> to <CTR>+d

So I need a way to send <CTR>+d and not <ESC> to the telnet server.

Anyone know how I can do this????


$ctrld=chr(4);
fwrite ($fp, $ctrld,1);


Thanks Jeppe, this worked fine...
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.