218 lines
9.4 KiB
HTML
218 lines
9.4 KiB
HTML
<!--startcut ==============================================-->
|
|
<!-- *** BEGIN HTML header *** -->
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML><HEAD>
|
|
<title>Converting Linux HOWTOs into Book Format LG #66</title>
|
|
</HEAD>
|
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#0000AF"
|
|
ALINK="#FF0000">
|
|
<!-- *** END HTML header *** -->
|
|
|
|
<CENTER>
|
|
<A HREF="http://www.linuxgazette.com/">
|
|
<H1><IMG ALT="LINUX GAZETTE" SRC="../gx/lglogo.png"
|
|
WIDTH="600" HEIGHT="124" border="0"></H1></A>
|
|
|
|
<!-- *** BEGIN navbar *** -->
|
|
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="correa.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue66/nielsen.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="nielsen2.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
|
|
<!-- *** END navbar *** -->
|
|
<P>
|
|
</CENTER>
|
|
|
|
<!--endcut ============================================================-->
|
|
|
|
<H4 ALIGN="center">
|
|
"Linux Gazette...<I>making Linux just a little more fun!</I>"
|
|
</H4>
|
|
|
|
<P> <HR> <P>
|
|
<!--===================================================================-->
|
|
|
|
<center>
|
|
<H1><font color="maroon">Converting Linux HOWTOs into Book Format</font></H1>
|
|
<H4>By <a href="mailto:articles@gnujobs.com">Mark Nielsen</a></H4>
|
|
</center>
|
|
<P> <HR> <P>
|
|
|
|
<!-- END header -->
|
|
|
|
|
|
|
|
|
|
<ol>
|
|
<li>
|
|
<a href="#Introduction">Introduction</a></li>
|
|
<li><a href="#perl">Perl script to convert the Postscript files</a></li>
|
|
|
|
<li>
|
|
<a href="#Conclusion">Conclusion</a></li>
|
|
<li>
|
|
<a href="#REF">References</a></li>
|
|
</ol>
|
|
|
|
|
|
<h3>
|
|
<a NAME="Introduction"></a>Introduction</h3>
|
|
I wanted to print out Linux HOWTOs into book format. However, I am not fond
|
|
of manually converting the HOWTOs. Instead, since all the HOWTOs are available
|
|
in Postscript format, I figured out that I could download the Postscript
|
|
files on a regular basis and use various tools to convert the Postscript
|
|
files into book formatted Postscript and PDF files. I accomplished this
|
|
with a relatively small Perl script using a variety of Unix tools. I plan on
|
|
have a cron job run at least once a week to update the books.
|
|
|
|
<a NAME="perl"></a>
|
|
<h3>Perl script to convert the Postscript files
|
|
</h3>
|
|
|
|
The Perl script is in this section, and you can
|
|
also <a href="misc/nielsen/HOWTO_Books.pl.txt">get the Perl script here</a>.
|
|
<pre>
|
|
|
|
#!/usr/bin/perl
|
|
|
|
# ftp://ftp.tardis.ed.ac.uk/users/ajcd/psutils.tar.gz
|
|
# http://www.dcs.ed.ac.uk/home/ajcd/psutils/
|
|
# cp Makefile.unix Makefile
|
|
# ln -s /usr/bin/perl /usr/local/bin/perl
|
|
# mkdir -p /usr/local/share/man/man1
|
|
# /usr/local/bin/psbook
|
|
|
|
#system ("lynx --source ftp://ftp.tardis.ed.ac.uk/users/ajcd/psutils.tar.gz > /tmp/psutils.tar.gz)";
|
|
# system ("cd /tmp; tar -zxvf psutils.tar.gz; cd psutils; cp Makefile.unix Makefile");
|
|
# system ("ln -s /usr/bin/perl /usr/local/bin/perl; mkdir -p /usr/local/share/man/man1");
|
|
# system ("cd /tmp/psutils; make; make install; ln -s /usr/local/bin/psutils /usr/bin/psutils");
|
|
|
|
# Ignore the lines above, unless you don't have psutils.
|
|
# I keep the lines above just so I remember how I installed psutils.
|
|
|
|
my $TempFile1 = "/tmp/HOWTO_Convert_1.ps";
|
|
my $TempFile2 = "/tmp/HOWTO_Convert_1.pdf";
|
|
my $SourceDir = "/root/HOWTO";
|
|
my $Destination = "/root/HOWTO_Books";
|
|
my $ZippedPDF = "/root/HOWTO_books_pdf.tgz";
|
|
my $ZippedPS = "/root/HOWTO_books_ps.tgz";
|
|
|
|
if (!(-d $Destination)) {system "mkdir $Destination";}
|
|
|
|
print "Downloading HOWTOs from http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/ps/Linux-ps-HOWTOs.tar.gz\n";
|
|
system ("lynx --source http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/ps/Linux-ps-HOWTOs.tar.gz > $SourceDir/Linux-ps-HOWTOs.tar.gz");
|
|
system ("cd $SourceDir; tar -zxvf Linux-ps-HOWTOs.tar.gz");
|
|
|
|
my @Files = <$SourceDir/*.ps.gz>;
|
|
|
|
foreach my $File (@Files)
|
|
{
|
|
my $command="gunzip -c $File | /usr/bin/psbook -s4 | mpage -2 > $TempFile1";
|
|
print "Executing psbook and mpage on $File\n$command\n";
|
|
system ($command);
|
|
$command = "ps2pdf $TempFile1 $TempFile2";
|
|
print "Executing ps2pdf\n$command\n";
|
|
system ($command);
|
|
|
|
my (@Temp) = split(/\//,$File);
|
|
my $NamePDF = pop @Temp;
|
|
my $NamePS = $NamePDF;
|
|
$NamePDF =~ s/\.ps\.gz$/\.pdf/;
|
|
$NamePS =~ s/\.ps\.gz$/\.ps/;
|
|
my $NewPS = "$Destination/$NamePS";
|
|
my $NewPDF = "$Destination/$NamePDF";
|
|
|
|
system ("mv $TempFile2 $NewPDF");
|
|
print "Created the book-formatted HOWTO, $NewPDF\n";
|
|
system ("mv $TempFile1 $NewPS");
|
|
print "Created the book-formatted HOWTO, $NewPS\n";
|
|
}
|
|
|
|
print "Creating zip files $ZippedPDF and $ZippedPS\n";
|
|
system ("tar -zcvf $ZippedPDF $Destination/*.pdf");
|
|
system ("tar -zcvf $ZippedPS $Destination/*.ps");
|
|
|
|
</pre>
|
|
|
|
<h3>
|
|
<a NAME="Conclusion"></a>Conclusion</h3>
|
|
|
|
This is just a simple Perl script I use to download and convert the
|
|
Postscript HOWTOs. My future goals involve:
|
|
<ol>
|
|
<li> using LWP in Perl instead of Lynx. Simple enough.
|
|
<li> converting the entire Perl script into Python.
|
|
<li> better error checking if the files don't get downloaded or if the
|
|
conversion doesn't work.
|
|
<li> creating objects accepting text, TeX, Postscript, PDF, or other formats
|
|
that can be converted into Postscript fairly easily and then into book format.
|
|
</ol>
|
|
|
|
For now, my simple Perl script works out just fine. I am interested in
|
|
converting other documents for people provided that the documentation falls
|
|
under some form of free documentation, like
|
|
<a href="http://www.gnu.org/philosophy/license-list.html#DocumentationLicenses">
|
|
Licenses For Documentation</a> located at www.gnu.org.
|
|
|
|
<h3>
|
|
<a NAME="REF"></a>References</h3>
|
|
|
|
<ol>
|
|
|
|
<li>10/2000 <a href="http://www.gnujobs.com/Articles/8/Book_Binding-3.html">Micro Publishing: Part 3 , by Mark Nielsen
|
|
</a>.
|
|
|
|
<li> 7-1-2000
|
|
<a href="http://genericbooks.com/Articles/5/Book_Binding-2.html">
|
|
Micro Publishing, part II (Mark's Update)</a>
|
|
|
|
<li> 12-1999 -- <a
|
|
href="http://genericbooks.com/Literature/Articles/1/Book_Binding-1.html">
|
|
Micro Publishing</a>.
|
|
<li>
|
|
If this article
|
|
changes, it will be available here
|
|
<a href="http://www.gnujobs.com/Articles/18/HOWTO_Books.html">
|
|
http://www.gnujobs.com/Articles/18/HOWTO_Books.html</a></li>
|
|
</ol>
|
|
|
|
<p>
|
|
<i> Mark works as an independent consultant donating time to causes like
|
|
GNUJobs.com, writing articles, writing free software, and working
|
|
as a volunteer at <a href="http://www.eastmont.net">eastmont.net</a>.</i>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- *** BEGIN bio *** -->
|
|
<SPACER TYPE="vertical" SIZE="30">
|
|
<p>
|
|
<h4><img align=bottom alt="" src="../gx/note.gif">Mark Nielsen</h4>
|
|
Mark works at ZING
|
|
(<A HREF="http://www.genericbooks.com">www.genericbooks.com</A>) and
|
|
<A HREF="http://GNUJobs.com">GNUJobs.com</A>. Previously,
|
|
Mark founded <A HREF="http://www.gnujobs.com">The Computer Underground</A>.
|
|
Mark works on non-profit and volunteer projects which promote free literature
|
|
and software. To make a living, he recruits people for GNU related jobs and
|
|
also provides solutions for web/database problems using Linux, FreeBSD, Apache,
|
|
Zope, Perl, Python, and PostgreSQL.
|
|
|
|
<!-- *** END bio *** -->
|
|
|
|
<!-- *** BEGIN copyright *** -->
|
|
<P> <hr> <!-- P -->
|
|
<H5 ALIGN=center>
|
|
|
|
Copyright © 2001, Mark Nielsen.<BR>
|
|
Copying license <A HREF="../copying.html">http://www.linuxgazette.com/copying.html</A><BR>
|
|
Published in Issue 66 of <i>Linux Gazette</i>, May 2001</H5>
|
|
<!-- *** END copyright *** -->
|
|
|
|
<!--startcut ==========================================================-->
|
|
<HR><P>
|
|
<CENTER>
|
|
<!-- *** BEGIN navbar *** -->
|
|
<IMG ALT="" SRC="../gx/navbar/left.jpg" WIDTH="14" HEIGHT="45" BORDER="0" ALIGN="bottom"><A HREF="correa.html"><IMG ALT="[ Prev ]" SRC="../gx/navbar/prev.jpg" WIDTH="16" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="index.html"><IMG ALT="[ Table of Contents ]" SRC="../gx/navbar/toc.jpg" WIDTH="220" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../index.html"><IMG ALT="[ Front Page ]" SRC="../gx/navbar/frontpage.jpg" WIDTH="137" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="http://www.linuxgazette.com/cgi-bin/talkback/all.py?site=LG&article=http://www.linuxgazette.com/issue66/nielsen.html"><IMG ALT="[ Talkback ]" SRC="../gx/navbar/talkback.jpg" WIDTH="121" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><A HREF="../faq/index.html"><IMG ALT="[ FAQ ]" SRC="./../gx/navbar/faq.jpg"WIDTH="62" HEIGHT="45" BORDER="0" ALIGN="bottom"></A><A HREF="nielsen2.html"><IMG ALT="[ Next ]" SRC="../gx/navbar/next.jpg" WIDTH="15" HEIGHT="45" BORDER="0" ALIGN="bottom" ></A><IMG ALT="" SRC="../gx/navbar/right.jpg" WIDTH="15" HEIGHT="45" ALIGN="bottom">
|
|
<!-- *** END navbar *** -->
|
|
</CENTER>
|
|
</BODY></HTML>
|
|
<!--endcut ============================================================-->
|