Solved

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

Posted on 2009-07-09
9
3,023 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
 
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 68

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now