|
-
Jan 29th, 2007, 11:51 PM
#1
Thread Starter
Lively Member
[Project] Making Telnet Connection
Hi there,
I am new to php. I would like to make a website that can make telnet connection. Connecting to the terminal server and login to the selected networking device. I saw this script (requires the other file as well) in a website for making telnet connection but i do not know what to put at the 'DoCommand' part so i only put 'enable'. When i load the page, i see 'enable Password: Password: '. How do i put the password in so that it will go be able to do the 'sh run' command? Anyone familiar with telnet connection?
PHP Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>
<body>
<?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('172.16.221.210','cisco','class'); //wwww.somewhere.com, username, password
switch ($result) {
case 0:
$telnet->DoCommand('enable', $result);
// NOTE: $result may contain newlines
echo $result;
$telnet->DoCommand('sh run', $result);
echo $result;
// say Disconnect(0); to break the connection without explicitly logging out
$telnet->Disconnect();
break;
case 1:
echo '[PHP Telnet] Connect failed: Unable to open network connection';
break;
case 2:
echo '[PHP Telnet] Connect failed: Unknown host';
break;
case 3:
echo '[PHP Telnet] Connect failed: Login failed';
break;
case 4:
echo '[PHP Telnet] Connect failed: Your PHP version does not support PHP Telnet';
break;
}
?>
</body>
</html>
|| ~ * FiOh * ~ ||
Different personality n character... alone,
difficult to understand n mysterious,
for I am... Princess Cindistine @ Another World.
You should know...
P.C - R.N.A.F. Yeah, that is ME...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|