Catálogo de publicaciones - libros
Shell Scripting Recipes: A Problem-Solution Approach
Chris F. A. Johnson
Resumen/Descripción – provisto por la editorial
No disponible.
Palabras clave – provistas por la editorial
Software Engineering/Programming and Operating Systems
Disponibilidad
Institución detectada | Año de publicación | Navegá | Descargá | Solicitá |
---|---|---|---|---|
No detectada | 2005 | SpringerLink |
Información
Tipo de recurso:
libros
ISBN impreso
978-1-59059-471-1
ISBN electrónico
978-1-4302-0024-6
Editor responsable
Springer Nature
País de edición
Reino Unido
Fecha de publicación
2005
Información sobre derechos de publicación
© Apress 2005
Cobertura temática
Tabla de contenidos
The POSIX Shell and Command-Line Utilities
Chris F. A. Johnson
There’s more to the shell than I have described in this chapter. It is only intended to explain some of the commands and concepts used in this book’s scripts, not be a tutorial on how to write shell scripts. Throughout the book, the scripts are commented to describe what is going on, but they do not always explain the syntax itself. This chapter has provided those explanations.
Pp. 1-40
Playing with Files: Viewing, Manipulating, and Editing Text Files
Chris F. A. Johnson
These scripts have looked at generic text files. The contents have been irrelevant (I consider line endings to be formatting, rather than content). Some of these, because they are not specific to any one file format, will show up in other chapters as commands used by those scripts.
Many other scripts throughout the book deal with file manipulation, from standard Unix configuration files to obscure formats for crossword puzzles. Some will be used to extract and present information from files, others will manipulate the files themselves, or create new ones.
Besides being useful on their own, these scripts can be modified to apply to different situations. Feel free to experiment, but, as always, experiment on copies of your files!
Pp. 41-60
String Briefs
Chris F. A. Johnson
These character and string functions only scratch the surface of the manipulations possible with the shell, and many more appear later in the book. In this chapter I presented basic functions that provide building blocks for more complex scripts. We have already seen functions used in other functions (_repeat in _substr, and _substr in -insert_str, for example); I provide a great deal more of that as the book progresses.
Pp. 61-79
What’s in a Word?
Chris F. A. Johnson
From composing crossword puzzles to solving the in your local newspaper, the scripts in this chapter can help you. If you want to know whether there was a seven-letter word on the rack you had in that Scrabble game, or whether you could have squeezed a word into , the tools are here.
Some of these scripts are of most use to cruciverbalists, but many can be used by anyone who plays word games.
Pp. 81-104
Scripting by Numbers
Chris F. A. Johnson
This chapter has barely scratched the surface of the numerical manipulations possible with shell scripts. There are more in other chapters, and no doubt you can think of many more, too.
Most of these scripts are very simple; a program doesn’t have to be complicated to be useful. You can create a new metric conversion script if you know the formula, and anything can be found on the Internet. (You don’t think I remembered them all, do you?)
Pp. 105-135
Loose Names Sink Scripts: Bringing Sanity to Filenames
Chris F. A. Johnson
I hope you have no doubt about my feelings regarding badly formed filenames. If shell scripts were never used, it wouldn’t matter. But despite the popularity of languages such as Perl and Python, it is exceedingly unlikely that shell scripts will ever disappear entirely. They are a natural complement to the command line.
You may have realized that, despite my ranting over @!$#%^*& filenames (I’ve run out of polite things to call them), I’ve just given you a chapter full of scripts that can process any filenames you can come up with. It is possible to do it, but a lot of scripting techniques are ruled out because of them. If you need to write shell scripts that work on spaced-out filenames, remember two things:
Pp. 137-155
Treading a Righteous PATH
Chris F. A. Johnson
PATH is one of the most important variables in a shell environment, but it can be awkward to do anything other than add a directory to it. If the current directory is added to the PATH, whether deliberately or accidentally, there are security issues. If an error is made in typing the name of a directory, commands may not be found, or the wrong commands may be executed.
The functions in this chapter provide a safe way to add and remove directories from the PATH, and validate existing entries.
Pp. 157-164
The Dating Game
Chris F. A. Johnson
A Multimedia communication system for blind users is developed. The system is named MIMIZU and its terminal is composed of a refreshable tactile graphic display and a stylus pen device that utilizes ultrasonic technologies. Blind users can make drawings directly on the tactile display surface with the stylus pen. It was originally developed as a drawing system with an erasing function. As the research progresses, we have noticed that it has a potential as a communication system for the blind with multimedia interactions. To implement the system, we made a pair of terminals and connected them by a network cable and developed communication software for a whiteboard application. Using the system, a pair of blind users can make and share tactile image information with each other. We describe results of a simple experiment in which one subject tried to transmit simple drawings to the other subject using this system. The tactile display’s resolution presented the difficulty in transmitting a circle, but the results were useful when transmitting shapes based on straight lines. Even when the subject is a circle, it is recognized when prior information is available. In addition to the communication software, we developed a type of ping-pong game for the system. The ball is shown by four pins arranged in a square and it moves from side to side. To play the game, players must hit the ball with a racket controlled by the stylus pen. The experiment with blind players showed that they could enjoy this game.
Pp. 165-184
Good Housekeeping: Monitoring and Tidying Up File Systems
Chris F. A. Johnson
The scripts in this chapter run the gamut from totally interactive (undup) to fully automated (dfcmp). Somewhere in between, symfix, sym2file, and zrm can do their work unhindered, or can prompt the user for confirmation of each action. Though designed for use at the command line, lsr needs no interaction, and can be used in scripts.
This is typical of a file management system, of which these scripts would be only a small part. Some tasks can be automated, but you will always want to control some things yourself. In addition to these, and the file-aging scripts in Chapter 14, you will probably need a good file manager. Some people swear by Midnight Commander (mc), others by Konqueror. My favorite is gentoo, which was based on the Amiga file manager, Directory Opus. Many applications also have interactive file managers: lynx, emacs, pine, and others.
In addition, you will probably need to write some more scripts to deal with your own particular situation.
Pp. 185-198
POP Goes the E-Mail
Chris F. A. Johnson
A typical day sees between 100 and 200 messages deleted from my mailboxes, and between 5 and 10 unwanted e-mails a day that get through my defenses. A few years ago, even that would have been considered unthinkable, but it is manageable. There are many systems available for blocking unsolicited bulk e-mail, but the spammers seem to keep one or two steps ahead. My scripts are not perfect, but nothing is. Once my scripts were in place, it took a while to adjust the filters, but I have hardly touched them in more than a year.
Pp. 199-227