# AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: Fedora RPM Guide\n" "POT-Creation-Date: 2011-03-02T00:57:14\n" "PO-Revision-Date: 2011-08-21 08:50+0000\n" "Last-Translator: Automatically generated\n" "Language-Team: Norwegian Bokmål \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Language: nb\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" #. Tag: title #, no-c-format msgid "Automating RPM with Scripts" msgstr "" #. Tag: para #, no-c-format msgid "This chapter covers:" msgstr "" #. Tag: para #, no-c-format msgid "Deciding when to program and when to script" msgstr "" #. Tag: para #, no-c-format msgid "Examining RPM files with scripts" msgstr "" #. Tag: para #, no-c-format msgid "Querying the RPM database with scripts" msgstr "" #. Tag: para #, no-c-format msgid "" "The rpm command provides a very high-level view of package management. Most " "of the operations you need to perform require only a single invocation. Some" " of the command-line options to the rpm command tend to get very complex, " "however, especially for detailed queries. That’s where scripting can help." msgstr "" #. Tag: para #, no-c-format msgid "" "This chapter covers scripting, specifically shell scripting, with the rpm " "command, especially for newcomers to Linux scripting" msgstr "" #. Tag: title #, no-c-format msgid "Scripting" msgstr "" #. Tag: para #, no-c-format msgid "" "Scripting allows you to quickly write new commands in a language, called a " "scripting language, that can help automate your work. Used heavily by system" " administrators and lightly by software developers, scripts can help remove " "some of the tedium from your day-to-day tasks. Scripts can also hold the " "complex query formats used with the rpm command so you don’t have to " "remember them." msgstr "" #. Tag: para #, no-c-format msgid "" "Scripts start out as text files. These text files hold commands in the " "scripting language. Most of these script file commands run commands " "installed on your system, such as rpm. To run a script, invoke a command, " "called an interpreter, that reads in the script file and executes the " "commands inside the script." msgstr "" #. Tag: para #, no-c-format msgid "" "Programming is usually considered different from scripting, even though " "there are many similarities. Programs start out as text files. These text " "files hold commands in the programming language and sometimes, not often, " "calls to commands installed on your system. Programs generally involve more " "work than scripts and are generally larger, containing more commands." msgstr "" #. Tag: para #, no-c-format msgid "" "Furthermore, most programs need to be compiled. A separate command parses " "the program text files and generates some form of machine code. Multiple " "pieces of a program may be linked together to form a command you can call " "from your shell prompt." msgstr "" #. Tag: para #, no-c-format msgid "" "Some programming languages, such as Java or C#, are compiled to a generic " "bytecode format. A compiled Java program, for example, is the same no matter" " what the architecture. To run such a program, you need a runtime engine " "such as the java command provides. (Runtime engine is a fancy term for " "interpreter.)" msgstr "" #. Tag: para #, no-c-format msgid "" "Such differences between scripting and programming sometimes get in the way " "of performing real work. For example, I once worked with a group of people " "who were convinced that they were not programmers. They felt that " "programming was an art that was far beyond them. Yet, they wrote hundreds of" " kilobytes of scripts to create a sophisticated graphical interface for a " "Computer-Aided Design system. In my mind, they were programming (and doing " "quite well at it). In their minds, though, there was a clear distinction " "between scripting@mdwhat they could do@mdand programming, which was beyond " "them, they thought." msgstr "" #. Tag: para #, no-c-format msgid "Don’t get caught up in this. Use the right tool for the job." msgstr "" #. Tag: title #, no-c-format msgid "Distinguishing Scripting Languages from Programming Languages" msgstr "" #. Tag: para #, no-c-format msgid "" "Experts differ regarding what defines a scripting language and what defines " "a programming language. It’s clear that languages such as Python blur the " "old distinction between programming and scripting." msgstr "" #. Tag: para #, no-c-format msgid "" "Originally, scripting was writing small files of commands that invoked other" " system commands. For example, you could write a script that wraps the Linux" " file command. Scripts were executed by scripting-language interpreters that" " parsed each command one at a time and then executed the command." msgstr "" #. Tag: para #, no-c-format msgid "" "Modern scripting languages, such as Tcl, are parsed at runtime and compiled " "into an internal bytecode format. Once compiled, there is no real difference" " from a language associated with programming such as Java." msgstr "" #. Tag: para #, no-c-format msgid "With a scripting language" msgstr "" #. Tag: para #, no-c-format msgid "" "*You generally don’t have to compile the script in advance. The scripting " "language interpreter may compile the program, often to an internal byte " "code, but you don’t have to invoke a compiler as a separate step." msgstr "" #. Tag: para #, no-c-format msgid "" "*The facilities of the language generally provide a higher level and more " "abstract level of interaction with the system than with programming " "languages. For example, writing socket-based networking code in Tcl requires" " a lot less code than writing the same code in a programming language such " "as C. Tcl provides a more abstract view of networking; therefore, your code " "is a lot simpler." msgstr "" #. Tag: para #, no-c-format msgid "" "*The commands in the scripting language are mostly the commands available to" " you on the command line. Scripting languages introduce their own commands, " "too." msgstr "" #. Tag: para #, no-c-format msgid "" "*The language is generally identified as a scripting language. This is more " "consensus than anything else. Forth is considered an interpreted programming" " language, while Perl is considered a scripting language." msgstr "" #. Tag: para #, no-c-format msgid "" "Table 15-1 lists some of the more common scripting and programming " "languages. Note that these are the generally-accepted categories for these " "languages, not hard and fast rules. This should not stop you, for example, " "from writing programs in Perl or Python. The distinctions between " "programming and scripting have blurred in recent years." msgstr "" #. Tag: para #, no-c-format msgid "Table 15-1 Common Scripting Languages and Common Programming Languages" msgstr "" #. Tag: para #, no-c-format msgid "Scripting Languages" msgstr "" #. Tag: para #, no-c-format msgid "Programming Languages" msgstr "" #. Tag: para #, no-c-format msgid "" "Bash (Bourne Again shell) Csh (C shell) JavaScript Ksh (Korn shell) Lua MS-" "DOS batch files Perl Python Ruby Sh (Bourne shell) Tcl" msgstr "" #. Tag: para #, no-c-format msgid "" "Assembler BASIC C C++ C# FORTRAN Forth Java LISP Modula-2, Modula-3 Oberon " "Pascal" msgstr "" #. Tag: title #, no-c-format msgid "Deciding When to Program and When to Script" msgstr "" #. Tag: para #, no-c-format msgid "" "Just as the distinction between programming and scripting languages has " "blurred in the last few years, so have the guidelines for when you should " "program and when you should script. The simplest rule remains, though: Use " "whatever techniques make you productive. In the end, no one really cares if " "you call it a program or a script." msgstr "" #. Tag: para #, no-c-format msgid "Even so, these guidelines may help:" msgstr "" #. Tag: para #, no-c-format msgid "" "*If you have to perform a lot of operations on a lot of RPMs, a program will" " likely perform much faster than a script that calls the rpm command over " "and over." msgstr "" #. Tag: para #, no-c-format msgid "*If the task is relatively simple, scripting generally works best." msgstr "" #. Tag: para #, no-c-format msgid "*If you are more experienced with a particular language, use it." msgstr "" #. Tag: para #, no-c-format msgid "" "*If you need to perform complex operations, perhaps involving transactions, " "a program is probably the right way to go." msgstr "" #. Tag: para #, no-c-format msgid "" "*In many cases, programming languages work better for creating graphical " "user interfaces, although Python and Perl offer graphical user interface " "toolkits, such as Perl/Tk or PyQt." msgstr "" #. Tag: para #, no-c-format msgid "There isn’t one right way to do it. Pick what works best for you." msgstr "" #. Tag: para #, no-c-format msgid "Cross Reference" msgstr "" #. Tag: para #, no-c-format msgid "" "This chapter covers shell scripting. " "covers C programming. covers " "Python scripting and programming, and covers Perl scripting." msgstr "" #. Tag: title #, no-c-format msgid "Shell Scripting Basics" msgstr "" #. Tag: para #, no-c-format msgid "" "For newcomers to scripting, don’t worry. A script, in this case a shell " "script, is merely a text file with commands mostly the same as the commands " "you can type at the keyboard. I’ll point out the differences." msgstr "" #. Tag: para #, no-c-format msgid "" "The following sections quickly introduce scripting for those new to this " "venture." msgstr "" #. Tag: title #, no-c-format msgid "Writing a script" msgstr "" #. Tag: para #, no-c-format msgid "For your first venture, enter the following script into a text file:" msgstr "" #. Tag: para #, no-c-format msgid "rpm -qa | grep rpm" msgstr "" #. Tag: para #, no-c-format msgid "" "This script has a two-part command. The rpm –qa part queries all RPM " "packages, as covered in . The grep rpm " "part finds only packages with rpm in their names. This is a very simple " "script, but it can serve to show how to work with scripts." msgstr "" #. Tag: para #, no-c-format msgid "" "Save this file under the name listrpmpkgs, since this script lists RPM " "packages." msgstr "" #. Tag: para #, no-c-format msgid "Note" msgstr "" #. Tag: para #, no-c-format msgid "" "If you’re new to Linux, you’ll notice there’s no program named Notepad.exe. " "There are, though, a plethora of Linux text editors to choose from. See " " for a listing of Linux text-" "editing tools." msgstr "" #. Tag: title #, no-c-format msgid "Running a script" msgstr "" #. Tag: para #, no-c-format msgid "" "Once you’ve entered a script, you can run it with the sh command, as shown " "following, passing the name of your script to the sh command:" msgstr "" #. Tag: para #, no-c-format msgid "$ sh listrpmpkgs" msgstr "" #. Tag: para #, no-c-format msgid "librpm404-devel-4.0.4-8x.27" msgstr "" #. Tag: para #, no-c-format msgid "librpm404-4.0.4-8x.27" msgstr "" #. Tag: para #, no-c-format msgid "rpm404-python-4.0.4-8x.27" msgstr "" #. Tag: para #, no-c-format msgid "rpm-4.1-1.06" msgstr "" #. Tag: para #, no-c-format msgid "rpm-devel-4.1-1.06" msgstr "" #. Tag: para #, no-c-format msgid "gnorpm-0.9-1" msgstr "" #. Tag: para #, no-c-format msgid "rpm-python-4.1-1.06" msgstr "" #. Tag: para #, no-c-format msgid "redhat-rpm-config-8.0-1" msgstr "" #. Tag: para #, no-c-format msgid "rpm-build-4.1-1.06" msgstr "" #. Tag: para #, no-c-format msgid "rpmrebuild-1.0-0" msgstr "" #. Tag: para #, no-c-format msgid "" "Type the command you have placed in your script at the command line. There " "should be no difference in the output. For example:" msgstr "" #. Tag: para #, no-c-format msgid "$ rpm -qa | grep rpm" msgstr "" #. Tag: title #, no-c-format msgid "Problems running scripts" msgstr "" #. Tag: para #, no-c-format msgid "" "The previous script example required the sh program, a Linux shell, to run " "the script. You also had to have the script file, such as listrpmpkgs, " "available. So, if you have stored the file in /home2/bin, to run the script," " use the following command:" msgstr "" #. Tag: para #, no-c-format msgid "$ sh /home2/bin/listrpmpkgs" msgstr "" #. Tag: para #, no-c-format msgid "" "That’s not very convenient. Furthermore, you always have to remember where " "you stored the script file listrpmpkgs. To make this command work better, " "you can turn your script into a command." msgstr "" #. Tag: title #, no-c-format msgid "Turning a script into a command" msgstr "" #. Tag: para #, no-c-format msgid "To turn a script into a command, do three simple things:" msgstr "" #. Tag: para #, no-c-format msgid "" "1.Add a special magic comment to the start of the file so Linux recognizes " "your text file as a command script." msgstr "" #. Tag: para #, no-c-format msgid "" "2.Change the permissions on the file so that it is marked as executable." msgstr "" #. Tag: para #, no-c-format msgid "3.Copy the file to a directory located in your command path." msgstr "" #. Tag: para #, no-c-format msgid "" "Shell scripts use a # to indicate a comment, text intended for human readers" " that can help explain the purpose of the script. By convention, Linux " "shells use a #! comment in the first line of a script file as a special " "marker that indicates the file is a shell script. The text that comes after " "the #! holds the name of the command that should be used to run the script. " "In almost all cases, that command should be /bin/sh for a shell script." msgstr "" #. Tag: para #, no-c-format msgid "" "So edit the listrpmpkgs script again, and add the magic comment so that the " "file reads as follows:" msgstr "" #. Tag: para #, no-c-format msgid "#!/bin/sh" msgstr "" #. Tag: para #, no-c-format msgid "Make sure the #! comment starts at the beginning of the first line." msgstr "" #. Tag: para #, no-c-format msgid "" "Next, change the permissions on the script to mark it as an executable " "program. Use the chmod command to do this. The chmod command changes the " "file permissions. To see the permissions, run the ls –l command before " "changing the permissions:" msgstr "" #. Tag: para #, no-c-format msgid "$ ls -l listrpmpkgs" msgstr "" #. Tag: para #, no-c-format msgid "-rw-rw-r-- 1 ericfj ericfj 31 Nov 7 20:02 listrpmpkgs" msgstr "" #. Tag: para #, no-c-format msgid "" "The first set of characters, the -rw-rw-r--, indicate the permissions in " "three batches: permissions for the file owner, the owner’s group of users, " "and world (everyone else). The rw means read and write, and the r alone " "means read only for everyone not the owner and not in the owner’s group." msgstr "" #. Tag: para #, no-c-format msgid "" "To add the permission to execute the file for the file owner only, use the " "following command:" msgstr "" #. Tag: para #, no-c-format msgid "$ chmod u+x listrpmpkgs" msgstr "" #. Tag: para #, no-c-format msgid "" "In this command, the u stands for the user who owns the file (for historical" " reasons, an o stands for others, not owner). The +x means add the x " "permission, short for execute permission." msgstr "" #. Tag: para #, no-c-format msgid "After running this command, you can see the revised permissions." msgstr "" #. Tag: para #, no-c-format msgid "-rwxrw-r-- 1 ericfj ericfj 31 Nov 7 20:02 listrpmpkgs" msgstr "" #. Tag: para #, no-c-format msgid "Use the man chmod command to see more information on this command." msgstr "" #. Tag: para #, no-c-format msgid "You now have a command you can run locally. For example:" msgstr "" #. Tag: para #, no-c-format msgid "$ ./listrpmpkgs" msgstr "" #. Tag: para #, no-c-format msgid "" "The next step is to copy the file to a directory in your system command " "path. To see which directories are in your path, run the following command:" msgstr "" #. Tag: para #, no-c-format msgid "$ echo $PATH" msgstr "" #. Tag: para #, no-c-format msgid "" "/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/ericfj/bin:/usr/java/j2sdk1.4.0_01/bin" msgstr "" #. Tag: para #, no-c-format msgid "" "Pick one of these directories. The /usr/local/bin directory is a common " "place to share locally created commands. If this is a personal command for " "your own use only, a directory under your home directory will be better. In " "this example, the /home/ericfj/bin is one such directory." msgstr "" #. Tag: para #, no-c-format msgid "" "Copy the script file to a directory in your command path, and you are ready " "to go." msgstr "" #. Tag: para #, no-c-format msgid "" "If you use the C shell, csh, or the T C shell, tcsh, you need to run the " "rehash command to tell the shell to look again at the set of commands " "available in your command path." msgstr "" #. Tag: para #, no-c-format msgid "Enter the following command:" msgstr "" #. Tag: para #, no-c-format msgid "$ listrpmpkgs" msgstr "" #. Tag: para #, no-c-format msgid "You have now extended the Linux command set with your own command." msgstr "" #. Tag: para #, no-c-format msgid "" "Windows users may be used to the convention that program file names end in " ".exe and scripts end in .bat or .cmd. When you run these programs or " "scripts, you don’t include the extension, exe, .bat, or .cmd. With Linux and" " UNIX, though, the full file name is important, so if you name your script " "rpminfo.bat, you must type rpminfo.bat each time you run the script. That’s " "why most Linux programs and scripts have no filename extension." msgstr "" #. Tag: para #, no-c-format msgid "" "If you want to share your script with others, you should give them the right" " to execute it as well. You can do that with the following command:" msgstr "" #. Tag: para #, no-c-format msgid "$ chmod a+x listrpmpkgs" msgstr "" #. Tag: para #, no-c-format msgid "In this case, the a stands for all users." msgstr "" #. Tag: title #, no-c-format msgid "Passing command-line options to your script" msgstr "" #. Tag: para #, no-c-format msgid "" "The listrpmpkgs script used so far isn’t very useful. It performs one " "command and that’s it. We cannot customize it without writing a new script." msgstr "" #. Tag: para #, no-c-format msgid "" "One way to make a script more flexible is to allow it to use command-line " "options. Just like the rpm command accepts a zillion options, you can make " "your scripts accept options." msgstr "" #. Tag: para #, no-c-format msgid "" "Shells define special variables for the command-line options passed to the " "shell. Table 15-2 lists these options." msgstr "" #. Tag: para #, no-c-format msgid "Table 15-2: Shell variables for command-line options" msgstr "" #. Tag: para #, no-c-format msgid "Variable" msgstr "" #. Tag: para #, no-c-format msgid "Holds" msgstr "" #. Tag: para #, no-c-format msgid "$0" msgstr "" #. Tag: para #, no-c-format msgid "The name of the script itself, from the command line" msgstr "" #. Tag: para #, no-c-format msgid "$1" msgstr "" #. Tag: para #, no-c-format msgid "The first option" msgstr "" #. Tag: para #, no-c-format msgid "$2" msgstr "" #. Tag: para #, no-c-format msgid "The second option" msgstr "" #. Tag: para #, no-c-format msgid "$3" msgstr "" #. Tag: para #, no-c-format msgid "The third option" msgstr "" #. Tag: para #, no-c-format msgid "$4" msgstr "" #. Tag: para #, no-c-format msgid "The fourth option" msgstr "" #. Tag: para #, no-c-format msgid "$5" msgstr "" #. Tag: para #, no-c-format msgid "The fifth option" msgstr "" #. Tag: para #, no-c-format msgid "$6" msgstr "" #. Tag: para #, no-c-format msgid "The sixth option" msgstr "" #. Tag: para #, no-c-format msgid "$7" msgstr "" #. Tag: para #, no-c-format msgid "The seventh option" msgstr "" #. Tag: para #, no-c-format msgid "$8" msgstr "" #. Tag: para #, no-c-format msgid "The eighth option" msgstr "" #. Tag: para #, no-c-format msgid "$9" msgstr "" #. Tag: para #, no-c-format msgid "The ninth option" msgstr "" #. Tag: para #, no-c-format msgid "$*" msgstr "" #. Tag: para #, no-c-format msgid "All command-line options" msgstr "" #. Tag: para #, no-c-format msgid "$#" msgstr "" #. Tag: para #, no-c-format msgid "Holds the number of command-line options" msgstr "" #. Tag: para #, no-c-format msgid "Use $#argv in place of $# if you use the C shell to run your scripts." msgstr "" #. Tag: para #, no-c-format msgid "" "You can use these variables to allow the user to pass the text to search " "for, instead of always searching for rpm. With this addition, your new " "script, renamed rpmgrep, follows in Listing 15-1:" msgstr "" #. Tag: para #, no-c-format msgid "Listing 15-1: rpmgrep" msgstr "" #. Tag: para #, no-c-format msgid "rpm -qa | grep $*" msgstr "" #. Tag: para #, no-c-format msgid "" "This script now expects a command-line option that holds the text to search " "for. Mark this script as an executable; then you can run it as follows:" msgstr "" #. Tag: para #, no-c-format msgid "$ ./rpmgrep python" msgstr "" #. Tag: para #, no-c-format msgid "python-devel-2.2.1-17" msgstr "" #. Tag: para #, no-c-format msgid "gnome-python2-gtkhtml2-1.99.11-8" msgstr "" #. Tag: para #, no-c-format msgid "gnome-python2-canvas-1.99.11-8" msgstr "" #. Tag: para #, no-c-format msgid "gnome-python2-1.99.11-8" msgstr "" #. Tag: para #, no-c-format msgid "orbit-python-1.99.0-4" msgstr "" #. Tag: para #, no-c-format msgid "gnome-python2-bonobo-1.99.11-8" msgstr "" #. Tag: para #, no-c-format msgid "gnome-python2-gconf-1.99.11-8" msgstr "" #. Tag: para #, no-c-format msgid "libxslt-python-1.0.19-1" msgstr "" #. Tag: para #, no-c-format msgid "libxml2-python-2.4.23-1" msgstr "" #. Tag: para #, no-c-format msgid "python-optik-1.3-2" msgstr "" #. Tag: para #, no-c-format msgid "python-2.2.1-17" msgstr "" #. Tag: para #, no-c-format msgid "mod_python-3.0.0-10" msgstr "" #. Tag: para #, no-c-format msgid "python-tools-2.2.1-17" msgstr "" #. Tag: para #, no-c-format msgid "" "If you want to make this command available, copy it to a directory in your " "command path as described in the preceding section." msgstr "" #. Tag: title #, no-c-format msgid "Examining RPM Files" msgstr "" #. Tag: para #, no-c-format msgid "" "When you work with a lot of RPM files, you’ll find that you run the same " "commands over and over again for each new package you get. For example, you " "may want to see what capabilities a package requires. You can type in the " "rpm command each time, or write a short shell script with the necessary " "command-line options. Listing 15-2 shows this script." msgstr "" #. Tag: para #, no-c-format msgid "Listing 15-2: rpmdepend" msgstr "" #. Tag: para #, no-c-format msgid "rpm -qp --requires $*" msgstr "" #. Tag: para #, no-c-format msgid "" "This script expects the name of an RPM package file. Run the command as " "follows:" msgstr "" #. Tag: para #, no-c-format msgid "$ rpmdepend vim-common-6.1-14.i386.rpm" msgstr "" #. Tag: para #, no-c-format msgid "rpmlib(PayloadFilesHavePrefix) <= 4.0-1" msgstr "" #. Tag: para #, no-c-format msgid "rpmlib(CompressedFileNames) <= 3.0.4-1" msgstr "" #. Tag: para #, no-c-format msgid "/bin/sh" msgstr "" #. Tag: para #, no-c-format msgid "/usr/bin/awk" msgstr "" #. Tag: para #, no-c-format msgid "libc.so.6" msgstr "" #. Tag: para #, no-c-format msgid "libc.so.6(GLIBC_2.0)" msgstr "" #. Tag: para #, no-c-format msgid "libc.so.6(GLIBC_2.1)" msgstr "" #. Tag: para #, no-c-format msgid "" "Another common task I perform involves listing all the files in an RPM along" " with the descriptive information on the package. This can really help, " "since so many Linux packages have nondescriptive names such as dia and " "anaconda." msgstr "" #. Tag: para #, no-c-format msgid "Listing 15-3 shows the rpminfo script." msgstr "" #. Tag: para #, no-c-format msgid "Listing 15-3: rpminfo" msgstr "" #. Tag: para #, no-c-format msgid "rpm -qilp $* | less" msgstr "" #. Tag: para #, no-c-format msgid "" "This script lists a potentially long set of lines, so the script pipes the " "output to the less command. For example:" msgstr "" #. Tag: para #, no-c-format msgid "$ ./rpminfo perl-XML-Dumper-0.4-22.noarch.rpm" msgstr "" #. Tag: para #, no-c-format msgid "Name : perl-XML-Dumper Relocations: /usr" msgstr "" #. Tag: para #, no-c-format msgid "Version : 0.4 Vendor: Red Hat, Inc." msgstr "" #. Tag: para #, no-c-format msgid "Release : 22 Build Date: Tue 06 Aug 2002 01:53:30 PM CDT" msgstr "" #. Tag: para #, no-c-format msgid "Install date: (not installed) Build Host: vegeta.devel.redhat.com" msgstr "" #. Tag: para #, no-c-format msgid "" "Group : System Environment/Libraries Source RPM: perl-XML-" "Dumper-0.4-22.src.rpm" msgstr "" #. Tag: para #, no-c-format msgid "Size : 10015 License: GPL" msgstr "" #. Tag: para #, no-c-format msgid "" "Signature : DSA/SHA1, Tue 06 Aug 2002 02:11:39 PM CDT, Key ID " "fd372689897da07a" msgstr "" #. Tag: para #, no-c-format msgid "Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>" msgstr "" #. Tag: para #, no-c-format msgid "URL : http://www.cpan.org" msgstr "" #. Tag: para #, no-c-format msgid "Summary : Perl module for dumping Perl objects from/to XML" msgstr "" #. Tag: para #, no-c-format msgid "Description :" msgstr "" #. Tag: para #, no-c-format msgid "XML::Dumper dumps Perl data to XML format. XML::Dumper can also read" msgstr "" #. Tag: para #, no-c-format msgid "XML data that was previously dumped by the module and convert it back" msgstr "" #. Tag: para #, no-c-format msgid "to Perl. Perl objects are blessed back to their original packaging;" msgstr "" #. Tag: para #, no-c-format msgid "if the modules are installed on the system where the perl objects are" msgstr "" #. Tag: para #, no-c-format msgid "reconstituted from xml, they will behave as expected. Intuitively, if" msgstr "" #. Tag: para #, no-c-format msgid "the perl objects are converted and reconstituted in the same" msgstr "" #. Tag: para #, no-c-format msgid "environment, all should be well." msgstr "" #. Tag: para #, no-c-format msgid "/usr/lib/perl5/vendor_perl/5.8.0/XML/Dumper.pm" msgstr "" #. Tag: para #, no-c-format msgid "/usr/share/man/man3/XML::Dumper.3pm.gz" msgstr "" #. Tag: para #, no-c-format msgid "" "I use this script so that I know what files a package wants to install." msgstr "" #. Tag: title #, no-c-format msgid "Querying the RPM Database" msgstr "" #. Tag: para #, no-c-format msgid "" "In addition to querying RPM files, you can script the commands you use to " "query the RPM database. This is most useful for the long commands with query" " formats, especially if you have a hard time remembering all the formats." msgstr "" #. Tag: title #, no-c-format msgid "Querying for all packages installed at the same time" msgstr "" #. Tag: para #, no-c-format msgid "" "If you want to list all the packages that were installed with the same " "transaction ID as a particular package, for example, you can use a script " "like rpmtran, in Listing 15-4." msgstr "" #. Tag: para #, no-c-format msgid "Listing 15-4: rpmtran" msgstr "" #. Tag: para #, no-c-format msgid "tid=`rpm -q --qf \"%{INSTALLTID}\\n\" $*`" msgstr "" #. Tag: para #, no-c-format msgid "rpm -q --tid $tid" msgstr "" #. Tag: para #, no-c-format msgid "" "This script uses the query format to get the transaction ID, or tid, for a " "particular package. It then passes this transaction ID to the rpm command to" " query for all packages installed with the same transaction ID." msgstr "" #. Tag: para #, no-c-format msgid "For example:" msgstr "" #. Tag: para #, no-c-format msgid "$ ./rpmtran tcl" msgstr "" #. Tag: para #, no-c-format msgid "itcl-3.2-74" msgstr "" #. Tag: para #, no-c-format msgid "tclx-8.3-74" msgstr "" #. Tag: para #, no-c-format msgid "tcl-8.3.3-74" msgstr "" #. Tag: para #, no-c-format msgid "tix-8.2.0b1-74" msgstr "" #. Tag: para #, no-c-format msgid "tkinter-2.2.1-17" msgstr "" #. Tag: title #, no-c-format msgid "Reading HTML documentation for a package" msgstr "" #. Tag: para #, no-c-format msgid "" "You can combine the rpm command with other commands as well. For example, " "the rpm –qd command lists the documentation files with a package. If this " "documentation is in HTML format, you can display this documentation in a Web" " browser such as Mozilla. Furthermore, by convention, the starting page for " "HTML documentation should be a file named index.html. Listing 15-5 combines " "all these factors:" msgstr "" #. Tag: para #, no-c-format msgid "Listing 15-5: rpmmoz" msgstr "" #. Tag: para #, no-c-format msgid "html_file=`rpm -qd $* | grep index.html | head -n 1 `" msgstr "" #. Tag: para #, no-c-format msgid "echo \"Launching Web browser with $html_file\"" msgstr "" #. Tag: para #, no-c-format msgid "htmlview $html_file &" msgstr "" #. Tag: para #, no-c-format msgid "" "This script searches for the documentation for a given package name, finds " "the first file named index.html, and launches the Web browser in the " "background to display this file, using the htmlview command which will " "likely run mozilla or your configured Web browser. When you run this " "command, you should see output like the following; then the Web browser " "should appear:" msgstr "" #. Tag: para #, no-c-format msgid "$ ./rpmmoz rpm-devel" msgstr "" #. Tag: para #, no-c-format msgid "" "Launching Web browser with /usr/share/doc/rpm-" "devel-4.1/apidocs/html/index.html" msgstr "" #. Tag: para #, no-c-format msgid "" "This script does not check for errors. If there are no files named " "index.html, the script launches the Web browser anyway. You could fix this " "by changing the script to validate the html_file variable prior to launching" " the Web browser." msgstr "" #. Tag: title #, no-c-format msgid "Where to Go From Here" msgstr "" #. Tag: para #, no-c-format msgid "" "This chapter just introduces the basics for shell scripting. There are many " "more things you can do. The online manual pages for the bash or tcsh " "commands provide a wealth of reference information on these shells." msgstr "" #. Tag: para #, no-c-format msgid "" "A number of Web sites provide tutorials on bash, including " "http://pegasus.rutgers.edu/~elflord/unix/bash-tute.html and " "www.linuxorbit.com/modules.php?op=modload&name=Sections&file=index&req=viewarticle&artid=459." " In addition, the Linux Documentation Project at www.tldp.org/guides.html " "provides a bash scripting guide, along with a number of bash- and shell-" "related how-to documents at www.tldp.org/HOWTO/HOWTO-INDEX/howtos.html." msgstr "" #. Tag: para #, no-c-format msgid "" "Teach Yourself Linux, by Steve Oualline and Eric Foster-Johnson (John Wiley " "& Sons, 2000), introduces a number of Linux topics, including text " "editors and scripting, for those new to Linux. And Graphical Applications " "with Tcl and Tk (Hungry Minds, Inc., 1997) by Eric Foster-Johnson, covers " "another scripting language, Tcl/Tk." msgstr "" #. Tag: para #, no-c-format msgid "" "Use your imagination. Any command that you run often or that is hard to type" " can be scripted. Furthermore, you can write complex scripts that automate " "some of the more tedious tasks you need to perform." msgstr "" #. Tag: title #, no-c-format msgid "Summary" msgstr "" #. Tag: para #, no-c-format msgid "" "Scripting is the art of writing a set of commands into text files to speed " "up your work. Programming is the art of writing a set of commands into text " "files, compiling the text files, and getting paid more. Choosing when to " "program and when to script isn’t always a clear-cut decision, but generally " "programs are move involved and complex, while scripts are shorter tools that" " automate your work. This chapter provides just a glimpse of all you can do " "with scripts and the RPM system." msgstr "" #. Tag: para #, no-c-format msgid "" "Scripts work very well for capturing obscure syntax options for the rpm " "command, especially the query formats. You can figure out a command once and" " then save the command as a script to save time in the future." msgstr "" #. Tag: para #, no-c-format msgid "" "Scripts aren’t the best choice for all tasks, though. In many cases, you " "need to write a program to accomplish your goals. The next chapter delves " "into the RPM C programming API, rpmlib." msgstr ""