Solved

Creating a batch file to control a Cisco Catalyst 2950 Switch Ports

Posted on 2009-07-09
9
3,220 Views
1 Endorsement
Last Modified: 2016-03-31
Hi experts,

I need to create a batch file / or any other method, that will enable a user in the Network Operation Center (who has no knowledge of Cisco IOS) to enable and disable certain ports on the Switch.
1
Comment
Question by:oneyg
9 Comments
 
LVL 3

Expert Comment

by:Magim_IT
ID: 24811931
Its very simple. You can create simple text file with the commands like this
To disable the port-
interface GigabitEthernet0/1
shut
To enable the port-
interface GigabitEthernet0/1
no shut
He just need to change the port number and copy paste these two lines after login on the switch. you can do multiple ports at time by adding same lines in single file or use interface range command.
 
0
 
LVL 8

Expert Comment

by:wiscom
ID: 24812172
Hi,

Whey make things difficult ? Use the GUI - Cluster Management Suite - Standard on the 2950 switches.
Enable on de switch http:
ip http server

login by browser (no username only password =enable secret)

You will see the switch graphically !!!

Right clik on "port" and select --> port settings --> by status you can enable/disable a port

Click and Play!

No mistakes can happen !!!

A/
0
 
LVL 1

Author Comment

by:oneyg
ID: 24812380
Thanks for the prompt reply guys

Magim IT:
I want to put thos command in a batch file so that just one click can do that. The thing I face is that whenevere I ran that batch file, It does not accept the entries written in the batch file and requires a user login and password. I do not want user to touch Cisco IOS!

This is the Batch File:
' Telnet 192.167.0.151
password (telnet password)
enable
config t
interface fastethernet0/5
shutdown
end
end
exit
logout'

the batch file to enable has no shutdown instead of a shutdown line.

Wiscom:
Yours is a good idea too. It was my first approach when tackling this issue. But when I use http I get the login that requires username and password (priviledge 15). But when I disable the port it does not want to save changes.
When you said 'ip http server' is that a command I should run to enable the feature you are refering to?

Thanks again for the prompt replies guys.

KR., Onesmo
0
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
LVL 34

Expert Comment

by:Istvan Kalmar
ID: 24812781
Hi,

I advise you to use privilege levels, cisco has (0 - 15) 15 is a superuser, you able to give policies to a privilege level!

Please refer this page:
http://www.cisco.com/en/US/docs/ios/security/configuration/guide/sec_cfg_sec_4cli_support_TSD_Island_of_Content_Chapter.html#wp1116277

If you want to enable it via radius see this:

http://www.cisco.com/en/US/tech/tk59/technologies_tech_note09186a008009465c.shtml

Best Regards,
Istvan

0
 
LVL 69

Expert Comment

by:Qlemo
ID: 24813088
The batch solution can either work with AutoIt, or (and that is how I do it) by using netcat (http://joncraton.org/files/nc111nt.zip). With netcat, you can do stuff like

(echo user
 echo password
 echo do-whatever
) | nc -t cisco.domain.local 23 -i 1

0
 
LVL 3

Expert Comment

by:Magim_IT
ID: 24820805
Hi,
Have a look at this link, maybe helpful to you
http://www.zdnetasia.com/techguide/network/0,3800010800,62037703,00.htm
 
0
 
LVL 3

Accepted Solution

by:
Magim_IT earned 125 total points
ID: 24821376
Hi,
Here is the script
  set  WshShell = WScript.CreateObject("WScript.Shell")
  WshShell.Run "cmd"
  WScript.Sleep 100
  WshShell.AppActivate "C:\Windows\system32\cmd.exe"
  WScript.Sleep 300
  WshShell.SendKeys "telnet 192.167.0.151{ENTER}"
  WScript.Sleep 300
  WshShell.SendKeys "telnet password"
  WshShell.SendKeys "{ENTER}"
  WScript.Sleep 300
  WshShell.SendKeys "configure terminal"
  WshShell.SendKeys "{ENTER}"
  WScript.Sleep 300
  WshShell.SendKeys "interface fastethernet0/5"
  WshShell.SendKeys "{ENTER}"
  WScript.Sleep 300

Save the file as .vbs and double click to run............Have a fun
1
 
LVL 1

Author Closing Comment

by:oneyg
ID: 31601477
This is Exactly what I wanted. Thanks a lot Magim IT. Now I am trying to get it in a web application on one of my servers and save this script there! But for this task I am giving out all the points I will give extra points for the next solutions.

Thanks again for this.
0
 

Expert Comment

by:Abdul Razzak
ID: 41530096
Dear
I want to know the script of logical ether-channel.
0

Featured Post

Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ACL Logging Optimization 7 46
Some help with Network Design 4 50
Unable to ping a server in the same subnet 10 90
Non-jumbo host to jumbo enabled switch: Will it work? 3 29
There are times where you would like to have access to information that is only available from a different network. This network could be down the hall, or across country. If each of the network sites have access to the internet, you can create a ne…
Hello to you all, I hear of many people congratulate AWS (Amazon Web Services) on how easy it is to spin up and create new EC2 (Elastic Compute Cloud) instances, but then fail and struggle to connect to them using simple tools such as SSH (Secure…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
After creating this article (http://www.experts-exchange.com/articles/23699/Setup-Mikrotik-routers-with-OSPF.html), I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question