473,396 Members | 2,129 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,396 software developers and data experts.

SSH connection script connecting to Cisco devices

Hello,

I have been looking around the net for a script to help me connect to and
help gather information from Cisco routers/switches. I have pieced together
a couple of different scripts from various different sources. I am having
issue when connecting to Cisco devices. For some reason the scripts
timesout/stops working just after the connection section of the script. It
does not give me a confirmation of completeion nor does it give me an error.
Since this same script works when connecting to any linux computer. I assume
the code is working correctly. I also assume that I am leaving out an
important piece of code out due to it not working properly when connecting
to a cisco device.

Anyone able to give advise, or direction on this? Any help would be greatly
appreciated.

Thanks,

dsx
--------------------------------------------------------------
<?
include("/var/www/config_files/config.inc");
?>

<html>
<head><?=$css;?></head>
<body>
<center><h3>NetMiner</h3></center><br>

<FORM METHOD="post" ACTION="<?=$_SERVER["PHP_SELF"];?>">
<b>Hostname: </b><input type=text name=host value="">
<INPUT NAME="reset" TYPE="reset" VALUE="Reset"><INPUT NAME="submit"
TYPE="submit" VALUE="Check Device">
</form>
<hr>

<?
if($_POST["submit"]){

$host = $_POST['host'];

echo "<b>Host:</b> <font color=green><b>[$host]... </b></font>";

echo "<b>Connection </b>";

if (!($resource=@ssh2_connect($host, 22))) {
echo "<font color=red><b>[FAILED]</b>... ";
exit(1);
} // End if
echo "<font color=green><b>[ok]</b></font>... ";

echo "<b>Authentication </b>";
if (!@ssh2_auth_password($resource,"USERNAME","PASSWO RD")) {
echo "<font color=red><b>[FAILED]</b></font>... ";
exit(1);
}
echo "<font color=green><b>[ok]</b></font>... ";

// We need a shell
echo "<b>Shell </b>";
if (!($stdio = @ssh2_shell($resource,"xterm"))) {
echo "<font color=red><b>[FAILED]</b></font>... ";
exit(1);
}
echo "<font color=green><b>[ok]</b></font>... ";

// Execution of any command
echo "<b>Command Execution </b>";
$command = "show cdp neighbors | include domainname.com\n";
fwrite($stdio,$command);
sleep(1);
echo "<font color=green><b>[ok]</b></font>... <br /><hr><br />";
while($line = fgets($stdio)) {
flush();
ob_flush();

$array[] = chop($line);

if (eregi('eastlink.ca', $array[$i])) {
if (!eregi('include eastlink.ca', $array[$i])) {
if ($array[$i] != $host) {
echo "<a href=\"get_cdp.php?host=$array[$i]\"
target=_blank>".$array[$i]."</a><br>";
} // end if
} // end if
} // end if

$i++;
} // End while

fclose($stdio);
} // End if
?>
</body>
</html>

Dec 12 '05 #1
0 3019

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alex Smith | last post by:
Hi all, I have an application that uses Oracle's JDBC thin driver 9.0.x to have a nice, friendly chat with 8.1.x database. During this exchange the server rudely interrupts the conversation and...
1
by: srinivas | last post by:
Hi, I need to move the file from one system to another system in secured network.For this client is using cisco vpn client.I need to check the cisco vpn connection state before moving the...
1
by: nivas.meda | last post by:
Hi, I need to move the file from one system to another system in secured network.For this client is using cisco vpn client.I need to check the cisco vpn connection state before moving the...
0
by: shabz | last post by:
Can CiscoWorks manage non snmp cisco devices, if yes how.
6
Cintury
by: Cintury | last post by:
Hi all, I've developed a mobile application for windows mobile 5.0 that has been in use for a while (1 year and a couple of months). It was developed in visual studios 2005 with a back-end sql...
3
by: bossingdarwin | last post by:
Hi Guys, I'm new to Perl and to this forum and I hope you gurus here help me. I am building a perl script that will telnet to one of my cisco router and execute commands. I was able to do this...
2
by: Nicolas Le Gland | last post by:
Hello everyone here. This is my first post in this newsgroup, I hope I won't be to much off-topic. Feel free to redirect me to any better group. I am getting strange timing issues when...
13
by: jkimbler | last post by:
As part of our QA of hardware and firmware for the company I work for, we need to automate some testing of devices and firmware. Since not everybody here knows C#, I'm looking to create a new...
2
by: manuitpro | last post by:
Hi, I have implemented a php script by which i can login to a router using fsockopen(), and i can run any cisco commands. But i have requiremnt login to a remote from from a central router for...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.