« Previous 1 2 3 4 Next »
Eat. Pray. Script.
Windows Automation
Windows administrators have native automation tools such as command scripting (think DOS batch files), PowerShell, and VBScript. If you administer heterogeneous systems (Windows, Linux, Unix), then you can, and should, create automation scripts using a single, cross-platform language as previously discussed. You might not be able to leverage Windows scripts on Linux systems, or vice versa, without some changes to them, but you only have to become expert in one language, instead of several.
Although projects are underway that attempt to port PowerShell to Linux, none are complete or completely successful. Perl, PHP, Expect, and Bash are examples of cross-platform language possibilities that operate similarly on Windows, Linux, and Unix systems.
If you install Cygwin, you have the advantage of Windows and Linux commands on the same system. This creates a powerful hybrid automation host that allows you to issue Windows command-line programs in a Bash shell operating environment. So, you have the best of both worlds: Windows and Linux. You can use Windows commands mixed with Linux commands. For example, if you want to see a list of all systems on your network that begin with the letters DAL , issue the command (in Cygwin):
bash-3.2$ net view | grep -i DAL \\DAL01 \\DAL02 \\DALAUTO \\DALV01
The only thing you have to remember when dealing with Windows systems in Cygwin’s Bash environment is the Windows whack whack wackiness. You have to add an extra whack for each whack in a command involving hostnames.
Using the standard syntax, throws an error:
bash-3.2$ psexec \\DAL01 ipconfig PsExec could not start \DAL01: The system cannot find the file specified.
Using a Bash-compatible syntax yields the desired information:
bash-3.2$ psexec \\DAL01 ipconfig Windows IP Configuration Ethernet adapter Local Area Connection 5: Connection-specific DNS Suffix . : IP Address. . . . . . . . . . . . : 192.168.1.235 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.254 ipconfig exited on XENAPP1 with error code 0. bash-3.2$
In Linux and Unix, the whack, or backslash (\), means that you want the system to ignore (leave as is) the next character that follows the whack. Therefore, when you use the standard Windows designation \\DAL01 , you get an error because Windows expects two whacks and you’ve given it one. You have to use four whacks to provide the system with the required two.
Another advantage of Cygwin on Windows is that you can also incorporate its executables into your command (cmd) batch files with expected results.
C:\Temp> DIR |grep resume.txt 10/07/2011 04:05 PM 52,824 resume.txt C:\Temp
Remember to enter C:\Cygwin\bin into your PATH environment variable so your system can find the executables. The same rule applies to PsTools executables.
Linux and Unix Automation
It’s possible to administer Linux and Unix systems, in a mixed environment, using a Windows automation system but it would be impossible to do it the other way around. Linux lacks a complete complement of Windows tools. There’s no Cygwin for Linux to make it possible. There are a few cross-platform tools in Linux but nothing as extensive as Cygwin for Windows.
The trend has always been in the Windows-to-Linux direction, which has left a gap for those who use Linux extensively and want to manage Windows systems with it. Until that situation changes, you’ll have to use a Windows system to manage other Windows systems.
Linux to Linux management and automation is easy. Hundreds of tools, both command line and GUI, exist to help you on your quest. However, like Windows, it is the power of the command line that rules in the automation world. GUI environments are optional on server systems, including your dedicated automation system.
It’s inconvenient and unsafe to create scripts that contain passwords, which execute interactively. Fortunately, Linux lends itself to non-password connectivity and automation through the magic of SSH keyfiles. Numerous references exist to teach you how to setup passwordless SSH (including SFTP and SCP) between hosts. This feature of SSH is compelling and useful to the administrator. Your alternative is to create shell scripts that pipe in passwords from text files or to use Expect scripts that contain passwords.
Another problem with storing passwords in scripts or files isn’t obvious but when passwords change, every script that contains a password will also need to change. This becomes a time-consuming, laborious and often frustrating task.
« Previous 1 2 3 4 Next »