Linux System Administration: A User's Guide
Now that you have had your introduction to scripting with expect, I am going to make the process almost impossibly easy. Rather than manually creating an expect script, how about letting a program do that for you, too? When you install expect, you will also install a cool little program called autoexpect. Simply put, autoexpect will watch whatever you are doing in an interactive session and create the expect script for you. Here is the format of the command:
autoexpect -f script_outputfile command_string
For instance, let's imagine that we wanted to log in to a remote system that is behind a firewall, essentially a two-step login process. After we log in to the firewall, we then execute a login (telnet, ssh, etc.) to yet another system on the internal network, then execute a standard menu program. We would like to have this whole process of logging in twice and starting this menu automated for us. From the command prompt, we would then type this command:
autoexpect -f superlogin.script telnet firewall.mycompany.comWhen you have finished your login, you can exit the menu and log out. autoexpect will have captured the entire session for you. Before running your new script, you will probably want to do some editing to clean things up a bit. autoexpect's output is probably a little wordier than you want. Furthermore, you will want to remove the lines that exit from your menu and log out, but the basics of the script and all the prompts are captured there for you. Make the script executable and you are almost done.
There is still one other thing you will want to add. At the end of your new expect script, add this command: interact
This tells expect to return control to you after it has done its work. Without it, expect closes the spawned process, and all you've managed to do is log in and log out very quickly.
In no way do I intend this to be the definitive reference on expect. I do, however, hope that this little introduction (indeed, this whole chapter) will serve to whet your appetite and inspire your imagination to explore other ways of developing constructive laziness. After all, we all have other work to do.
What's all this on your screen about a magic cloak?
|illusive networks' Deceptions Everywhere||Aug 29, 2016|
|Happy Birthday Linux||Aug 25, 2016|
|ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs||Aug 24, 2016|
|Updates from LinuxCon and ContainerCon, Toronto, August 2016||Aug 23, 2016|
|NVMe over Fabrics Support Coming to the Linux 4.8 Kernel||Aug 22, 2016|
|What I Wish I’d Known When I Was an Embedded Linux Newbie||Aug 18, 2016|
- illusive networks' Deceptions Everywhere
- Happy Birthday Linux
- New Version of GParted
- Download "Linux Management with Red Hat Satellite: Measuring Business Impact and ROI"
- What I Wish I’d Known When I Was an Embedded Linux Newbie
- All about printf
- Updates from LinuxCon and ContainerCon, Toronto, August 2016
- ContainerCon Vendors Offer Flexible Solutions for Managing All Your New Micro-VMs
- Blender for Visual Effects
With all the industry talk about the benefits of Linux on Power and all the performance advantages offered by its open architecture, you may be considering a move in that direction. If you are thinking about analytics, big data and cloud computing, you would be right to evaluate Power. The idea of using commodity x86 hardware and replacing it every three years is an outdated cost model. It doesn’t consider the total cost of ownership, and it doesn’t consider the advantage of real processing power, high-availability and multithreading like a demon.
This ebook takes a look at some of the practical applications of the Linux on Power platform and ways you might bring all the performance power of this open architecture to bear for your organization. There are no smoke and mirrors here—just hard, cold, empirical evidence provided by independent sources. I also consider some innovative ways Linux on Power will be used in the future.Get the Guide