ZDNet UK


Skip to Main Content

ZDNet.co.uk - Winner of Best Business Website 2007
  1. Home
  2. News
  3. Blogs
  4. Reviews
  5. Prices
  6. Resources
  7. Community
  8. My ZDNet

 

ZDNet UK RSS Feeds


IT Jobs

Office applications Toolkit

Scripting - the basics

Allen V. Rouse MCSE, MCDBA, CCNA

Published: 11 Mar 2003 10:18 GMT

  • Email
  • Trackback
  • Clip Link
  • Print friendly
  • Post Comment

Network administrators have used scripting since long before Windows or even DOS came on the scene. Unix administrators, for instance, have been using shell scripting and its powerful capabilities for decades. Scripting can significantly ease the burden of network administration. But learning to create useful and effective scripts for networking tasks is not easy and requires a lot of patience and practice. Before you begin, it's important to have a good understanding of what scripting is and why it is so useful.

In this article on scripting, I will provide information to help you understand how scripting can play a role in network maintenance and management. In subsequent articles, I will talk about the various scripting languages and platforms, basic programming concepts for scripting, and using Windows shell scripting and Visual Basic scripting for network administration. I'll also point you toward other resources that are available for learning how to write scripts.

What is scripting?
Simply stated, a script is a small, interpreted program that can carry out a series of tasks and make decisions based on specific conditions it finds. By "interpreted," we mean that when it is run, it is carried out one line at a time, as opposed to "compiled," which is the process of turning it into machine language before it is run. A script is created using ASCII text, so Windows Notepad or a similar text editor is the only tool required.

A number of scripting "languages" are available for you to choose from, each with its own capabilities and limitations. These languages include Windows native shell scripting, Visual Basic Scripting Edition, JavaScript, Kixtart, and Perl. Which one you choose will ultimately depend on a combination of the tasks required and your own experience and inclinations.

Each scripting language has a collection of commands or keywords and a set of rules on how to use them. The set of rules for writing a script in any given language is called the syntax. Once you learn the keywords and syntax, you can use a text editor to write the script and then save it with a file extension that is appropriate to the scripting language you are using. Some of the more common file extensions you will see are .bat, .cmd, .vbs, .js, and .kix.

How is scripting used?
Scripting lets you automate various network administration tasks, such as those that are performed every day or even several times a day. For example, login scripts run every time a user logs in to the network and can perform tasks like mapping network drives for the user based on certain conditions, such as group membership. Another example of script use might be a situation where you want to have each Windows NT server create a new Emergency Restore Disk and then copy the contents of that disk to a network location.

Other tasks might need to be carried out only once, such as a modification to the registry, but to a large number of servers that are widely distributed geographically. In a case like that, you could create and distribute a single script to run the task on each server.

You can start scripts manually, but you can also start them automatically, either by a specific event or scheduled via the Windows Task Scheduler. Windows NT allows scripts to be run automatically each time a user logs in to the network. Windows 2000 goes much further and can be configured to automatically run separate scripts upon:

  • Machine startup
  • Machine shutdown
  • User login
  • User logout
You could, for instance, map specific network drives when a user logs in and then automatically copy that user's Favorites folder to a network share when he or she logs out so that the data is preserved in a central location.

The scripting advantage
Scripting in network administration offers significant advantages. It allows you to:

  • Save time -- Scripts can carry out complex tasks and be invoked automatically, without the intervention of the network administrator, so the admin can concentrate on other tasks while the script runs.
  • Be consistent -- A script need be written only once and can then be invoked many times. It is much less error-prone than manually carrying out the task each time.
  • Be flexible -- Scripts can use decision-making logic to respond to different conditions. Rather than statically mapping a workstation to persistent drives, for example, network drives can be mapped in a variety of ways based on which user is logging on to the machine. You could write a script to check whether a file exists and delete it if it does or display an error message if it doesn't. The only real limit to scripting is your imagination.

Summary
As you can see, learning to create scripts for automating network administration is well worth the effort, even if it does require some work. In my next article, I will discuss the various choices you have in scripting languages and platforms.


For a weekly round-up of the enterprise IT news, sign up for the
Enterpise newsletter.

Find out what's where in the new Tech Update with our
Guided Tour.

Tell us what you think in the
Enterprise Mailroom.

  • Email
  • Trackback
  • Clip Link
  • Print friendly Print with Dell

Did you find this article useful?
36 out of 72 people found this useful


Full Talkback thread

0 comments


Company/Topic Alerts

Create a new alert from the list below:













Related Jobs

Script Developer. London. 35,000 - 45,000. Java / C Programming

Scripters interface with clients business and technical representatives as well as business analysts to determine requirements, then produce and test ...

IT Help Desk Analyst

To carry out additional housekeeping and administrative tasks as required. Ability to resolve conflict directly or through escalation - Knowledge of ...

Internet Team Leader

Good working knowledge of scripting languages i.e. To assist with the production of test plans, test scripts and the conduct of tests. Internet Team ...

Featured Talkback

Why do so many (virtually all) software packages think that they are so important that they have to be started automatically every time the computer boots? What is the largest number of "speed access", "update check", "camera download" and whatever other background programs you have ever seen running? Of those, how many did you really need?

By: J.A. Watson

Read full story:
Annoying software: a rogues' gallery

Discussions

keithmv keithmv

Password Deadlock

Saturday 26 July 2008, 12:02 PM

2 comments

Vista Upgrade Blog

Microsoft's pre-modern message puts a...

Over at ZDNet.com, Ed Bott reports a first sighting of Microsoft's eagerly awaited $300 million ad campaign. Already the cause of much speculation, the consensus is that this will be... More

8 comments

A $40 CONSUMER-class router has create...

Believe it or not I don't work in IT, haven't for 7 years. Yes I work with Microsoft's Windows XP Embedded and as a result I have to know a lot about the OS, the kernal, Win API calls... More

Post a comment

Sick Puppy Redo

I generally follow a dispassionate investigative process when trying to discern what happened when a project goes bad. Although its a low priority item, it gets done simply because... More

Post a comment