0

I'm new to linux and want to create a pdf from an asciidoc using a toolchain.

Running

a2x -fpdf -dbook --fop essayv1.txt  

in the shell works fine. I wanted to write a script to automate that, so I wrote this and put it into create.sh:

myfile="/media/essay/essayv1"
rm -f ${myfile}.pdf
a2x -fpdf -dbook --fop ${myfile}.txt

However, running this via sh create.sh only gives me

.txt ERROR: missing SOURCE_FILE: /media/essay/essayv1

Can someone tell me how to fix that simple script?

2
  • 1
    Did you edit this script with an editor that put Windows line-endings in it? Run dos2unix or similar on your create.sh.
    – twalberg
    Jan 22, 2014 at 19:45
  • Thanks, that's the solution. As simple as that and I've wasted hours trying to fix it.
    – helm
    Jan 23, 2014 at 15:10

1 Answer 1

0

Try :

#!/bin/sh
myfile="/media/essay/essayv1"
cd `dirname "${myfile}.txt"`
rm -f ${myfile}.pdf
a2x -fpdf -dbook --fop "${myfile}.txt"
3
  • Got the same error as before, now in addition create.sh: 3: cd: can't cd to /media/essay Typing cd /media/essay into the shell works, though
    – helm
    Jan 22, 2014 at 18:50
  • Directory /media/essay exist ? And the file /media/essay/essayv1.txt exist ?
    – Georgio
    Jan 22, 2014 at 18:54
  • Definitely, I can access them via normal shell commands. I may add that this Ubuntu is running in VirtualBox and "essay" is a folder shared with the Windows host machine, but I assumed that would make no difference for handling the files in it.
    – helm
    Jan 22, 2014 at 18:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.