Dateiformate konvertieren

mit OpenOffice

OpenOffice kann auf der Komandozeile schon einiges, wie zum Beispiel automatisiertes Drucken. Um Dateiformate zu konvertieren muss man einen OpenOffice Server starten und dann mit einem Pythonscript die Datei über eine standardisierte UNO-Schnittstelle von OpenOffice umwandeln lassen. Da man hierfür einiges anstellen muss, gibt es zur Erleichterung ein Paket mit dem Namen „unoconv“. Dieses Programm braucht mindestens diese drei Parameter:

  1. Backend (document, graphics, presentation, spreadsheet)
  2. Zielformat (mit „unoconv –show“ kann man sich alle anzeigen lassen)
  3. Quelldatei[en]

und so wird es bedient:

Vorbereitung

# yum install unoconv
# aptitude install unoconv

Server starten

# unoconv -l &

oder mit spezieller Portangabe

# unoconv -l -p 2002 &

Liste der möglichen Zielformate anzeigen (OpenOffice Version 3.1.1-5ubuntu1.1)

# unoconv --show

bzw.

# unoconv -s 127.0.0.1 -p 2002 --show
The following list of document formats are currently available:
  bib      - BibTeX [.bib]
  doc      - Microsoft Word 97/2000/XP [.doc]
  doc6     - Microsoft Word 6.0 [.doc]
  doc95    - Microsoft Word 95 [.doc]
  docbook  - DocBook [.xml]
  html     - HTML Document (OpenOffice.org Writer) [.html]
  odt      - Open Document Text [.odt]
  ott      - Open Document Text [.ott]
  ooxml    - Microsoft Office Open XML [.xml]
  pdb      - AportisDoc (Palm) [.pdb]
  pdf      - Portable Document Format [.pdf]
  psw      - Pocket Word [.psw]
  rtf      - Rich Text Format [.rtf]
  latex    - LaTeX 2e [.ltx]
  sdw      - StarWriter 5.0 [.sdw]
  sdw4     - StarWriter 4.0 [.sdw]
  sdw3     - StarWriter 3.0 [.sdw]
  stw      - Open Office.org 1.0 Text Document Template [.stw]
  sxw      - Open Office.org 1.0 Text Document [.sxw]
  text     - Text Encoded [.txt]
  txt      - Plain Text [.txt]
  vor      - StarWriter 5.0 Template [.vor]
  vor4     - StarWriter 4.0 Template [.vor]
  vor3     - StarWriter 3.0 Template [.vor]
  xhtml    - XHTML Document [.html]
The following list of graphics formats are currently available:
  bmp      - Windows Bitmap [.bmp]
  emf      - Enhanced Metafile [.emf]
  eps      - Encapsulated PostScript [.eps]
  gif      - Graphics Interchange Format [.gif]
  html     - HTML Document (OpenOffice.org Draw) [.html]
  jpg      - Joint Photographic Experts Group [.jpg]
  met      - OS/2 Metafile [.met]
  odd      - OpenDocument Drawing [.odd]
  otg      - OpenDocument Drawing Template [.otg]
  pbm      - Portable Bitmap [.pbm]
  pct      - Mac Pict [.pct]
  pdf      - Portable Document Format [.pdf]
  pgm      - Portable Graymap [.pgm]
  png      - Portable Network Graphic [.png]
  ppm      - Portable Pixelmap [.ppm]
  ras      - Sun Raster Image [.ras]
  std      - OpenOffice.org 1.0 Drawing Template [.std]
  svg      - Scalable Vector Graphics [.svg]
  svm      - StarView Metafile [.svm]
  swf      - Macromedia Flash (SWF) [.swf]
  sxd      - OpenOffice.org 1.0 Drawing [.sxd]
  sxd3     - StarDraw 3.0 [.sxd]
  sxd5     - StarDraw 5.0 [.sxd]
  tiff     - Tagged Image File Format [.tiff]
  vor      - StarDraw 5.0 Template [.vor]
  vor3     - StarDraw 3.0 Template [.vor]
  wmf      - Windows Metafile [.wmf]
  xhtml    - XHTML [.xhtml]
  xpm      - X PixMap [.xpm]
The following list of presentation formats are currently available:
  bmp      - Windows Bitmap [.bmp]
  emf      - Enhanced Metafile [.emf]
  eps      - Encapsulated PostScript [.eps]
  gif      - Graphics Interchange Format [.gif]
  html     - HTML Document (OpenOffice.org Impress) [.html]
  jpg      - Joint Photographic Experts Group [.jpg]
  met      - OS/2 Metafile [.met]
  odd      - OpenDocument Drawing (Impress) [.odd]
  odg      - OpenOffice.org 1.0 Drawing (OpenOffice.org Impress) [.odg]
  odp      - OpenDocument Presentation [.odp]
  otp      - OpenDocument Presentation Template [.otp]
  pbm      - Portable Bitmap [.pbm]
  pct      - Mac Pict [.pct]
  pdf      - Portable Document Format [.pdf]
  pgm      - Portable Graymap [.pgm]
  png      - Portable Network Graphic [.png]
  pot      - Microsoft PowerPoint 97/2000/XP Template [.pot]
  ppm      - Portable Pixelmap [.ppm]
  ppt      - Microsoft PowerPoint 97/2000/XP [.ppt]
  pwp      - PlaceWare [.pwp]
  ras      - Sun Raster Image [.ras]
  sda      - StarDraw 5.0 (OpenOffice.org Impress) [.sda]
  sdd      - StarImpress 5.0 [.sdd]
  sdd3     - StarDraw 3.0 (OpenOffice.org Impress) [.sdd]
  sdd4     - StarImpress 4.0 [.sdd]
  sti      - OpenOffice.org 1.0 Presentation Template [.sti]
  stp      - OpenDocument Presentation Template [.stp]
  svg      - Scalable Vector Graphics [.svg]
  svm      - StarView Metafile [.svm]
  swf      - Macromedia Flash (SWF) [.swf]
  sxi      - OpenOffice.org 1.0 Presentation [.sxi]
  tiff     - Tagged Image File Format [.tiff]
  vor      - StarImpress 5.0 Template [.vor]
  vor3     - StarDraw 3.0 Template (OpenOffice.org Impress) [.vor]
  vor4     - StarImpress 4.0 Template [.vor]
  vor5     - StarDraw 5.0 Template (OpenOffice.org Impress) [.vor]
  wmf      - Windows Metafile [.wmf]
  xhtml    - XHTML [.xml]
  xpm      - X PixMap [.xpm]
The following list of spreadsheet formats are currently available:
  csv      - Text CSV [.csv]
  dbf      - dBase [.dbf]
  dif      - Data Interchange Format [.dif]
  html     - HTML Document (OpenOffice.org Calc) [.html]
  ods      - Open Document Spreadsheet [.ods]
  ooxml    - Microsoft Excel 2003 XML [.xml]
  pdf      - Portable Document Format [.pdf]
  pts      - OpenDocument Spreadsheet Template [.pts]
  pxl      - Pocket Excel [.pxl]
  sdc      - StarCalc 5.0 [.sdc]
  sdc4     - StarCalc 4.0 [.sdc]
  sdc3     - StarCalc 3.0 [.sdc]
  slk      - SYLK [.slk]
  stc      - OpenOffice.org 1.0 Spreadsheet Template [.stc]
  sxc      - OpenOffice.org 1.0 Spreadsheet [.sxc]
  vor3     - StarCalc 3.0 Template [.vor]
  vor4     - StarCalc 4.0 Template [.vor]
  vor      - StarCalc 5.0 Template [.vor]
  xhtml    - XHTML [.xhtml]
  xls      - Microsoft Excel 97/2000/XP [.xls]
  xls5     - Microsoft Excel 5.0 [.xls]
  xls95    - Microsoft Excel 95 [.xls]
  xlt      - Microsoft Excel 97/2000/XP Template [.xlt]
  xlt5     - Microsoft Excel 5.0 Template [.xlt]
  xlt95    - Microsoft Excel 95 Template [.xlt]

Das sind 118 Formate, die OpenOffice in der Version 3.1 versteht!

Client aufrufen (Schematisch)

# unoconv -s [unoconv-Server] -p 2002 -d [Dokumententyp] -f [Zielformat] [Quelldatei] [Quelldatei]
# unoconv -s [unoconv-Server] -p 2002 -d [document, graphics, presentation, spreadsheet] -f [pdf, odt, ods, doc, xls, csv, `unoconv --show`] [Quelldatei] [Quelldatei]

Beispiel:

eine Excel-Datei in eine CSV-Datei umwandeln:

# unoconv -d spreadsheet -f csv Originaldatei.xls

eine OpenDokument-Tabelle in eine Excel-Datei umwandeln (mit Angabe des Servers und des Ports):

# unoconv -s 127.0.0.1 -p 2002 -d spreadsheet -f xls Originaldatei.ods

die simple Kommandozeile, alles in einem:

# unoconv -l & unoconv -d spreadsheet -f xls Originaldatei.ods

CSV => XLS mit Python

Leider wird csv nicht als Eingabeformat/Quellformat akzeptiert! Deshalb hat jemand ein Python-Script geschrieben, mit dem man CSV-Dateien in XLS-Dateien umwandeln kann. Um dieses Script nutzen zu können muss man erst das Modul „pyExcelerator“ installiern. Dieses Modul kann Excel-97/2000/XP/2003-Dateien erzeugen, man kann es von hier beziehen (es steht unter BSD-Lizenz):

Installation

# unzip -L ~/Downloads/pyexcelerator-0.6.4.1.zip
# cd pyexcelerator-0.6.4.1/
# python setup.py install

Anwendung

# ./csv2xls.py -h
# ./csv2xls.py -o test.xls test.csv
# ./csv2xls.py -s';' -t -o test.xls test.csv

Die meisten machen sowas mit Excel oder OpenOffice per Hand, einige machen das auch mit Perl.

mit Ghostscript

# aptitude install ps2eps ghostscript

Text (PDF -> PS -> TXT)

# pdf2ps Originaldatei.pdf datei.ps
# ps2ascii datei.ps > datei.txt
/home/bin/pdf2txt.sh
#!/usr/bin/env bash
if [ -z "${1}" ] ; then
        echo "${0} Datei1.pdf Datei2.pdf Datei3.pdf"
        exit 1
fi
if [ -z "$(which pdf2ps)" ] ; then
        echo "pdf2ps (Ghostscript) ist nicht installiert"
        exit 1
fi
if [ -z "$(which ps2ascii)" ] ; then
        echo "ps2ascii (Ghostscript) ist nicht installiert"
        exit 1
fi
for _datei in ${@}
do
        DATEINAME="$(echo "$(basename ${_datei})" | rev | sed 's/.*[.]//' | rev)"
        pdf2ps ${_datei} ${DATEINAME}.ps
        ps2ascii ${DATEINAME}.ps > ${DATEINAME}.txt && rm -f ${DATEINAME}.ps
done

Grafik (PDF -> PS -> EPS)

In einzelne Seiten (mit einer Auflösung von 300 dpi) zerlegen:

# pdf2ps -r300 dokument.pdf dokument_%04d.ps
# ls -1
dokument.pdf
dokument_0001.ps
dokument_0002.ps
dokument_0003.ps
dokument_0004.ps

Auf A4-Format umsetzen:

# ps2eps -f -s a4 dokument_0001.ps

Auf A4-Format umsetzen und dabei um 90 Grad rechts rum drehen:

# ps2eps -f -s a4 -R + dokument_0002.ps

Auf A4-Format umsetzen und dabei um 90 Grad links rum drehen:

# ps2eps -f -s a4 -R - dokument_0003.ps

Auf A4-Format umsetzen und dabei um 180 Grad drehen:

# ps2eps -f -s a4 -R ^ dokument_0004.ps
# ls -1
dokument.pdf
dokument_0001.ps
dokument_0002.ps
dokument_0003.ps
dokument_0004.ps
dokument_0001.eps
dokument_0002.eps
dokument_0003.eps
dokument_0004.eps

A4-hoch im JPEG-Format (ferlustbehaftet):

# cat dokument_0001.eps | gs -q -dNOPAUSE -g595x842 -sDEVICE=jpeg -sOutputFile=dokument_0001.jpg

A4-quer im PNG-Format (ferlustfrei, hat aber weniger Farben als TIFF):

# cat dokument_0002.eps | gs -q -dNOPAUSE -g842x595 -sDEVICE=png48 -sOutputFile=dokument_0002.png

Diese Seite wieder ins PDF-Format umwandeln:

# gs -dSAFER -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=dokument_0003.pdf -f dokument_0003.ps

A4-quer im TIFF-Format (ferlustfrei):

# cat dokument_0004.eps | gs -q -dNOPAUSE -g842x595 -sDEVICE=tifflzw -sOutputFile=dokument_0004.tif

Aus verschiedenen Postscriptdateien oder eps-Dateien kann man auch wieder eine PDF-Datei machen:

# gs -dSAFER -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=dokument_neu.pdf -f dokument_0001_resize.ps dokument_0002_resize.ps dokument_0003_resize.ps

oder

# gs -dSAFER -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=dokument_neu.pdf -f dokument_0001_resize.eps dokument_0002_resize.eps dokument_0003_resize.eps

Kurzanleitung

Ghostscript

# pdf2ps datei.pdf datei.ps
# gs -sDEVICE=jpeg -sOutputFile=datei.jpg datei.ps
weitere Optionen
-q
-dBATCH
-pA4
-sDEVICE=epswrite
-sDEVICE=tiffg4
-sDEVICE=png
-sDEVICE=jpeg -dJPEGQ=75 -r600 (Qualität:75, DPI:600)

mit ImageMagick

Die erste Seite aus dem oben zerlegten PDF-Dokument soll hier um 90° links herum gedreht und ins A4-Format gebracht werden.

Diese PostScript-Datei soll mit einer Auflösung von 300x300dpi gelesen werden, das stellt in diesem Fall die Ausgangsqualität dar.

# convert -density 300x300 original.ps -rotate 270 -resize 595x842 ergebnis.png

oder

# convert -density 300x300 original.ps -rotate 270 -repage a4 ergebnis.png

oder

# convert -density 300x300 original.ps -rotate 270 -repage a4 -quality 95 ergebnis.png

Hier wird ein JPEG-Bild, im Originalformat 2479×3508, in eine PNG-Datei ins 595×842-Format (A4) konvertiert:

# convert -size 2479x3508 original.jpg -rotate 270 -resize 595x842 -quality 95 ergebnis.png

Das Ergebnis kann auch eine Postscriptdatei sein:

# convert -density 300x300 original.ps -rotate 270 -repage a4 ergebnis.ps

Auch PDF-Dateien kann man hiermit bauen:

# convert -density 300x300 dokument_0001.ps -density 300x300 dokument_0002.ps -density 300x300 dokument_0003.ps -repage a4 dokument_a4.pdf

So kann man erfahren, was in einer Bilddatei steckt:

# identify dokument_0001.ps
dokument_0001.ps PS 1191x842 1191x842+0+0 16-bit DirectClass 1.448MiB 0.070u 0:00.079

Kurzanleitung

Standard

# convert Datei.pdf Datei.png
# convert -density 72 Datei.pdf Datei.png

leicht vergrößert

# convert -density 100 Datei.pdf Datei.png

stark vergrößert

# convert -density 300x300 Datei.pdf Datei.png

in ein Einheitsformat bringen

# identify Bild.jpg
Bild.jpg JPEG 1191x842 1191x842+0+0 16-bit DirectClass 1.448MiB 0.070u 0:00.079
# convert -size 1191x842 Bild.jpg -resize 720x576 -background black -compose Copy -gravity center -extent 720x576 -quality 95 Bild_720x576.png
/home/bin/bilder_resize.sh
#!/bin/bash
BILD="${1}"
NEFORMAT="720x576"        # Einheitsformat
BNAME="$(basename ${BILD} | rev | awk '{sub("[.]"," ");print $2}' | rev)"
OFORMAT="$(identify  | awk '{print $3}' || exit 1)"
convert -size ${OFORMAT} ${BILD} -resize ${NEFORMAT} -background black -compose Copy -gravity center -extent ${NEFORMAT} -quality 95 ${BNAME}_${NEFORMAT}.png

so wird das Script angewendet:

# /home/bin/bilder_resize.sh Bild.jpg

mit AbiWord

(Tex und AbiWord müssen installiert sein)

# abiword --to=latex datei.doc
# latex --interaction=batchmode datei.latex
# dvigif datei.dvi

Webseite auf der Kommandozeile saugen und umwandeln

einfach nur saugen

# wget -F --no-check-certificate https://heins.info/wiki/doku.php?id=vernetzung -O vernetzung.html

DokuWiki-Seiten saugen und als statische Webseite ablegen

Das im folgenden beschriebene Vorgehen wurde an diesem Wiki getestet.

zu Fuß

Eine dynamische Seite (in diesem Fall eine „DokuWiki“-Seite) vom Home-Server saugen und als statische HTML-Seiten ablegen, damit man sie auf den gemieteten Webserver hoch laden kann.

Das ist sinnvoll, wenn man nur eine billige Webseite bei einem billigen Web-Hoster gemietet hat, auf der man bestimmte Dinge nicht tun kann, weil dort praktisch nichts installiert wurde.

Dann baut man sich zu Hause seinen Web-Server mit vollem Funktionsumfang auf und konvertiert die dynamischen Seiten dann in statische, die dann ins Internet hochgeladen werden können, oder auch auf einen USB-Stick abgelegt werden können.

# wget -F --no-check-certificate https://www.heins.info/wiki/doku.php?id=vernetzung -O - | sed -e 's#href="/wiki/lib/exe/#href="#' -e 's#<a href=.*id=#<a href="#' -e 's#<img src=".*media=#<img src="#g' -e 's#" class="wikilink#.html" class="wikilink#' -e 's#<a href=".*;media=#<a href="#' > vernetzung.html

Jetzt müssen noch die Bilder ins Verzeichnis kopiert werden.

Beim Dokuwicki könnte man das so machen:

# cp /usr/share/dokuwiki/data/pages/* .

Oder man saugt sie sich auch mit wget.

per Script

Dieses Script wurde auf Ubuntu 10.04 erstellt und getestet:

# vi wiki2usb.sh
#!/bin/bash
ZIEL0="/tmp/tmpwiki"
ZIEL1="/tmp/wiki"
WIKISERVER="https://www.heins.info/wiki"
### veraltetetn Kram löschen
rm -fr ${ZIEL0} ${ZIEL1}
### benötigte Verzeichnisse wieder anlegen
mkdir -p ${ZIEL0} ${ZIEL1}
### Arbeitsverzeichnis testen
cd ${ZIEL1} || exit 1
### ins Temp-Verzeichnis wechseln
cd ${ZIEL0} || exit 1
### erstmal das Icon
wget -F --no-check-certificate "${WIKISERVER}/lib/tpl/default/images/favicon.ico" -O ${ZIEL1}/favicon.ico
### HTML-Dateien saugen
#
wget -F --no-check-certificate "${WIKISERVER}/doku.php?id=start" -O start.html
wget -F --no-check-certificate "${WIKISERVER}/doku.php?do=index&id=Start" -O index.html
cat index.html | fgrep '<li class="level1"><div class="li"><a href="' | sed -e 's#<li class="level1"><div class="li"><a href="/wiki/doku.php?id=##' | awk -F'"' '{print $1}' 2> /dev/null | egrep -v '^$' | while read WIKI
do
    wget -F --no-check-certificate "${WIKISERVER}/doku.php?id=${WIKI}" -O ${WIKI}.html
done
### die HTML-Dateien fuer Offline-Betrieb anpassen
#
ls *.html | egrep -v '^$' | sed 's#\.html##' | while read USBWIKI
do
        cat ${USBWIKI}.html | sed \
        -e 's#<a href="/wiki/doku.php".*accesskey="h" title="\[H\]">#<a href="index.html" accesskey="h" title="\[H\]">#' \
        -e 's#\[\[<a href=".*amp;do=backlink"  title="Links hierher">#\[\[<a href="start\.html"  title="Links hierher">#' \
        -e 's#<link rel="search" href=.*##' \
        -e 's#<link rel="start" href=.*##' \
        -e 's#<link rel="contents" href=.*##' \
        -e 's#<link rel="canonical" href=.*##' \
        -e 's#<link rel="alternate" type=".*##' \
        -e 's#href="/wiki/lib/exe/#href="#' \
        -e 's#<a href=.*id=#<a href="#' \
        -e 's#<img src=".*media=#<img src="#g' \
        -e 's#<a href="fetch.php?.*media=#<a href="#' \
        -e 's#" class="wikilink#.html" class="wikilink#' \
        -e 's#<a href=".*;media=#<a href="#' \
        -e 's#<link rel="stylesheet" media="all" type="text/css" href="css.php?s=all&amp;t=default&amp;tseed=[0-9]*" />#<link rel="stylesheet" media="all"    type="text/css" href="all.css" />#g' \
        -e 's#<link rel="stylesheet" media="screen" type="text/css" href="css.php?t=default&amp;tseed=[0-9]*" />#<link rel="stylesheet" media="screen" type="text/css" href="screen.css" />#g' \
        -e 's#<link rel="stylesheet" media="print" type="text/css" href="css.php?s=print&amp;t=default&amp;tseed=[0-9]*" />#<link rel="stylesheet" media="print"  type="text/css" href="print.css" />#g' \
        -e 's#favicon.ico#favicon.ico#' \
        -e 's#<input type="submit" value="Zeige Quelltext".*/>##' \
        -e 's#<input type="submit" value="Ältere Versionen".*/>##' \
        -e 's#<input type="submit" value="Letzte Änderungen".*/>##' \
        -e 's#<input type="submit" value="Suche".*/>##' \
        -e 's#<input type="submit" value="Anmelden".*/>##' \
        -e 's#<input type="submit" value="Übersicht".*/>##' \
        -e 's#<input type="button" class="button" value="Nach oben".*/>##' \
        -e 's#<input type="submit" value="Seite anzeigen".*/>##' \
        -e 's#<img src=".*/indexer.php.*/>##' \
        -e 's#href="start&amp;do=backlink"#href="start.html"#' \
        -e 's#.*<span class="bchead">Zuletzt angesehen:</span>.*#<span class="bchead">Zuletzt angesehen:</span><span class="bcsep">\&raquo;</span><a href="start.html" class="breadcrumbs" title="start">start</a></span></div>#' \
        -e 's#.*<span class="bchead">Sie befinden sich hier: </span>.*##' \
        | egrep -v '^$' \
        > ${ZIEL1}/${USBWIKI}.html
done
### Jetzt die Bilder zu den Seiten
cat *.html | tr -s '"' '\n' | egrep '^/wiki/' | egrep -v '^/wiki/$|doku.php$|feed.php$' | sort | uniq | sed 's#/wiki/##' | egrep '<img src="|class="media' | fgrep -v 'lib/exe/indexer.php' | while read URL
do
        DATEI="$(echo "${URL}" | awk -F'=' '{print $NF}')"
        wget -F --no-check-certificate "${WIKISERVER}/${URL}" -O ${ZIEL1}/${DATEI}
done
### ind Arbeitsverzeichnis wechseln
cd ${ZIEL1} || exit 1
### CSS-Dateien
#
wget -F --no-check-certificate "${WIKISERVER}/lib/exe/css.php?s=all&amp;t=default&amp;tseed=1274567601" -O /tmp/all.css
cat /tmp/all.css | sed -e 's#}#}³#g' -e 's#(/wiki/lib/images/fileicons/#(#g' -e 's#(/wiki/lib/images/interwiki/#(#g' -e 's#(/wiki/lib/images/#(#g' | tr -s '³' '\n' > all.css
wget -F --no-check-certificate "${WIKISERVER}/lib/exe/css.php?t=default&amp;tseed=1274567601" -O /tmp/screen.css
cat /tmp/screen.css | sed -e 's#}#}³#g' -e 's#(/wiki/lib/images/fileicons/#(#g' -e 's#(/wiki/lib/images/interwiki/#(#g' -e 's#(/wiki/lib/images/#(#g' | tr -s '³' '\n' > screen.css
wget -F --no-check-certificate "${WIKISERVER}/lib/exe/css.php?s=print&amp;t=default&amp;tseed=1274567601" -O /tmp/print.css
cat /tmp/print.css | sed -e 's#}#}³#g' -e 's#(/wiki/lib/images/fileicons/#(#g' -e 's#(/wiki/lib/images/interwiki/#(#g' -e 's#(/wiki/lib/images/#(#g' | tr -s '³' '\n' > print.css
### Dateien, auf die in den CSS-Dateien verwiesen wird
#
cat /tmp/all.css /tmp/screen.css /tmp/print.css | sed -e 's#}#}³#g' | tr -s '³' '\n' | sed -e 's#.*(/wiki/##g' -e 's#).*##g' | egrep '^lib/' | while read DATEI
do
        DDDD="$(basename "${DATEI}")"
        wget -F --no-check-certificate "${WIKISERVER}/${DATEI}" -O ${DDDD}
done
rm -fr ${ZIEL0} /tmp/all.css /tmp/screen.css /tmp/print.css

Jetzt das Script starten:

# sh wiki2usb.sh

Wenn das Script gelaufen ist, wird ein Verzeichnis (in diesem Fall ist es “/tmp/wiki“) existieren, in dem alle nötigen Dateien für das Wiki im Offline-Betrieb liegen.

Gestartet wird das Wiki dann zum Beispiel so:

# firefox /tmp/wiki/index.html

oder so

# firefox /tmp/wiki/start.html

Webseite auf der Kommandozeile ins PDF-Format umwandeln

  1. weil man bei Google keine XPI-Datei hoch laden kann, ist sie als ZIP-Datei hochgeladen worden. Die ZIP-Datei muss jetzt ausgepackt werden, so das man nur noch die XPI-Datei hat.
  2. Plugin installieren: Mozilla Browser (Firefox) starten und dann über „Datei“ → „Datei öffnen…“, dann die XPI-Datei wählen und öffnen.
  3. Browser neu starten
# firefox -print https://server.de/seite.php -printmode pdf -printfile seite.pdf

Und jetzt per Script eine Liste abarbeiten lassen.

Als erstes erstellen wir uns eine Liste von URL's:

# vi /tmp/urlliste.txt
https://heins.info/wiki/doku.php?id=vernetzung
http://sites.google.com/site/torisugari/commandlineprint2
http://www.pro-linux.de/news/1/print/15757/native-zfs-unterstuetzung-fuer-linux-vorgestellt.html

Die Liste darf auch noch viel länger sein… ;-)

Und jetzt wandeln wir diese URL's in PDF-Dateien um:

#!/bin/sh
QUELLE="/tmp/urlliste.txt"
ZIEL="/tmp"
cat ${QUELLE} | egrep -v '^$' | while read URL
do
      firefox -print ${URL} -printmode pdf -printfile ${ZIEL}/${URL}.pdf
done
 
Falls nicht anders bezeichnet, ist der Inhalt dieses Wikis unter der folgenden Lizenz veröffentlicht:GNU Free Documentation License 1.2
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki