php and telnet (again)
Posted: Wed Aug 22, 2007 10:51 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hello,
I'm currently building a intranet webpage in php for my employer and he has asked me to integrate a script that checks the status on one of our servers.
the server is an IBM running AIX on the same network as the host server.
I can view the status by loggin into the server as root and using hummingbird (software) or using telnet.
the command im using to see the status is: topas which displays (see image 1)
what i managed to do so far is use the script provided [url=http://www.geckotribe.com/php-telnet/]by Antone Roundy[/url] and connect to the server but not using the root username and password.
i know this doesnt tell a right lot so i'm gonna put some more screenshots on to tell you what i am doing when loggin onto the server using the root username and password.
on image 2 you input the root username and password, on images 3-5 you have to select through the option till you are able to input the topas command.
when using the script (modified it a bit) im trying to get past the first few return keys prompts but it is not letting me do it. and one know how i can get around this?
thanks
[b]Mark[/b]
[url=http://mddigital.co.uk/mark/topas.jpg]image 1[/url]
[url=http://mddigital.co.uk/mark/login1.JPG]image 2[/url]
[url=http://mddigital.co.uk/mark/login2.JPG]image 3[/url]
[url=http://mddigital.co.uk/mark/login3.JPG]image 4[/url]
[url=http://mddigital.co.uk/mark/login4.JPG]image 5[/url]Code: Select all
<?php
require_once "PHPTelnet.php";
$telnet = new PHPTelnet();
$telnet->show_connect_error=0;
// if the first argument to Connect is blank,
// PHPTelnet will connect to the local host via 127.0.0.1
$result = $telnet->Connect('server.ip,'username','password');
switch ($result) {
case 0:
echo "start telnet<br>";
$telnet->DoCommand('\r\n', $result);
ffile($result);
$telnet->DoCommand('\r\n', $result);
ffile($result);
/*
$telnet->DoCommand('', $result);
ffile($result);*/
// say Disconnect(0); to break the connection without explicitly logging out
echo "end telnet<br>";
ffile("\nEND\n");
$telnet->Disconnect();
break;
case 1:
ffile( '[PHP Telnet] Connect failed: Unable to open network connection');
break;
case 2:
ffile( '[PHP Telnet] Connect failed: Unknown host');
break;
case 3:
ffile( '[PHP Telnet] Connect failed: Login failed');
break;
case 4:
ffile( '[PHP Telnet] Connect failed: Your PHP version does not support PHP Telnet');
break;
}
function ffile($result)
{
$File = "log.txt";
//a = amend, w = write
$Handle = fopen($File, 'a');
$Data = $result;
fwrite($Handle, $Data);
echo $result;
}
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]