You are not logged in.
hi! im creating a little script to view pdf files within midnight commander, but i get stuck, i don't know what's wrong with the script, seems like it doesn't find the file $1 basename, obviously im forgetting something...
the script:
#!/bin/bash
pdftohtml $1
BASE=$(basename $1 .pdf)
FILE1=$($BASE.html)
FILE2=$($BASE_ind.html)
FILE3=$($BASEs.html)
elinks $FILE1
rm $FILE1
rm $FiLE2
rm $FILE3
the output:
[aleyscha@aleyscha New]$ viewpdf UNIX-LINUX\ Shell\ Commands.pdf
pdftohtml version 0.36 http://pdftohtml.sourceforge.net/, based on Xpdf version 3.00
Copyright 1999-2003 Gueorgui Ovtcharov and Rainer Dorsch
Copyright 1996-2004 Glyph & Cog, LLC
Usage: pdftohtml [options] <PDF-file> [<html-file> <xml-file>]
-f <int> : first page to convert
-l <int> : last page to convert
-q : don't print any messages or errors
-h : print usage information
-help : print usage information
-p : exchange .pdf links by .html
-c : generate complex document
-i : ignore images
-noframes : generate no frames
-stdout : use standard output
-zoom <fp> : zoom the pdf document (default 1.5)
-xml : output for XML post-processing
-hidden : output hidden text
-nomerge : do not merge paragraphs
-enc <string> : output text encoding name
-dev <string> : output device name for Ghostscript (png16m, jpeg etc)
-v : print copyright and version info
-opw <string> : owner password (for encrypted files)
-upw <string> : user password (for encrypted files)
-nodrm : override document DRM settings
basename: extra operand `Commands.pdf'
Try `basename --help' for more information.
/home/aleyscha/bin/viewpdf: line 4: .html: command not found
/home/aleyscha/bin/viewpdf: line 5: .html: command not found
/home/aleyscha/bin/viewpdf: line 6: .html: command not found
rm: missing operand
Try `rm --help' for more information.
rm: missing operand
Try `rm --help' for more information.
rm: missing operand
Try `rm --help' for more information.
Press any key to continue...
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery
Offline
Try
#!/bin/bash
#first, convert the pdf to html format.
pdftohtml $1
_base=`basename $1 .pdf`
_file1=${_base}.html
_file2=${_base}_ind.html
_file3=${_base}s.html
elinks ${_file1}
rm ${_file1} ${_file2} ${_file3}
edit: note that this really isn't optimized very well, but for a simple script it should work.
Last edited by iBertus (2008-04-20 20:33:01)
Offline
You need to put double quotes around your variable, otherwise bash interrupts them separately:
pdftohtml "$1"
Offline
You need to put double quotes around your variable, otherwise bash interrupts them separately:
pdftohtml "$1"
Ah, it took me a minute to figure out why you would need this, but then dawned on me that multi-work filenames would break the script.
Offline
Thanks for the replyes!! but still doesnt work...
now it outputs:
(elinks reporting that the file ".html" doesn't exist) and when exiting elinks...
rm: cannot remove `.html': No such file or directory
rm: cannot remove `_ind.html': No such file or directory
rm: cannot remove `s.html': No such file or directory
Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.
-- Antoine de Saint-Exupery
Offline