473,395 Members | 1,745 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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

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
5 6174
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

"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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Christian Wilcox | last post by:
I'm trying to programmatically access information from a telnet session which is normally accessed with a telnet program capable of terminal emulation (currently set at VT320). The initial login...
2
by: Eshrath | last post by:
Hi, What I am trying to do: ======================= I need to form a table in html using the xsl but the table that is formed is quite long and cannot be viewed in our application. So we are...
6
by: Matthew Wieder | last post by:
I have the following requirements: Build a stand-alone C# application that asks the user to click in a cell in an Excel spreadsheet, and then displays the address of that cell in the C#...
14
by: Motion Musso aka: Sathia | last post by:
Hi, I'm trying to have two input field ie: who |mickey mouse| <- value is "mickey mouse" when |12...| |12-5-2005|
7
by: =?ISO-8859-1?Q?Une_B=E9vue?= | last post by:
i'm in search of an online syntax highlighter able to highlight either JavaScript, CSS or HTMl only or a whole page. the result would be shown on the page itself, on demand. -- Une Bévue
4
by: coaxfiber | last post by:
Hi guys, my problem is when I installing the Apache v2.2.4 as my local server to run my php, and then run the test configuration, it tells me this error: httpd.exe: Syntax error on line 152 of...
5
by: Mirxon | last post by:
Hello, I'm working on a C program under Ubuntu. It's basd on socket. Browser calls a client cgi (C program), and send some parameters to server (C program). Server runs another program...
12
by: LayneMitch via WebmasterKB.com | last post by:
Hello everyone. I'm currently learning Javascript and doing a few exercises. One problem I'm working on takes an array of names from an xml file using Ajax and writes it to...
12
by: neovantage | last post by:
Hi, I am working on an image to process it with different ways/options given in the page. My page name is cart and it has an uploaded image having thumbnail view. When i click on that thumbnail...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.