473,750 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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($addr ess,$port);
$s='o';
$s=fgets($fp,12 8); //the telnet server responds when connected
echo("<br>$s<br >");

fputs ($fp, "SOME-COMMAND"); //some command to order a rapport
$s=fgets($fp,12 8);
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,'EN D')) { // supposed to get the printout
$t=fgets ($fp,128); // that never comes
echo("<br>$t");
}
fclose($fp);
?>
Jul 17 '05 #1
5 6203
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($addr ess,$port);
$s='o';
$s=fgets($fp,1 28); //the telnet server responds when connected
echo("<br>$s<b r>");

fputs ($fp, "SOME-COMMAND"); //some command to order a rapport
$s=fgets($fp,1 28);
echo("<br>$s<b r>"); //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,'EN D')) { // 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.i s> wrote in message
news:51******** *************** ***@posting.goo gle.com...
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($addr ess,$port);
$s='o';
$s=fgets($fp,12 8); //the telnet server responds when connected
echo("<br>$s<br >");

fputs ($fp, "SOME-COMMAND"); //some command to order a rapport
$s=fgets($fp,12 8);
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,'EN D')) { // 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
3972
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 text displays fine, of course, but when I get to the section which displays extended ASCII characters, Telnet from telnetlib displays the following garbled mess: ?[?40h?[?3l?[0;1m?>?[?1l?[?25l?[?3l?[0;0H?[2J?[?25l?(B??[0;7m?[23B ba6.0 version...
2
3231
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 writing one object in C# which will take the entire table tag contents and renders. Ie., we need to pass "<table>………… <thead>……</thead>. <tr>.<td> <td>..<tr>.<td> <td> </table>" content to
6
12505
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# application. It seems simple enough, but the problem I'm encountering is as follows: In order for the user to select the cell from Excel, they must first click once on the Excel window to give it focus and then their second click is what changes the cell...
14
2839
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
3472
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
6289
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 C:/Program Files/Apache Software Foundati on/Apache2.2/conf/httpd.conf: C:/Program Files/Apache Software Foundation/Apache 2.2/conf/httpd.conf:152: <"C:/Program> was not closed. Note the errors or messages above, and press the <ESC> key to exit. ...
5
4960
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 (ooimpress, open office ppt), and translate the commands from client to a key event, and send it to child process. For example.
12
2332
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 <select<optionstags. This is the code they use:
12
11407
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 it opens in a highfi technology thickbox. In my cart there are more than 1 images which can be process/manuplate with different options given in the cart. Now what i want is that i need to send some extra values as a parameters so that i can...
0
8840
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9399
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9345
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9259
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6083
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4717
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4895
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3328
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.