Method: PDFToImage.exec

Defined in:
lib/pdftoimage.rb

.exec(cmd, error = nil) ⇒ String

Executes the specified command, returning the output.

Parameters:

  • cmd (String)

    The command to run

Returns:

  • (String)

    The output of the command



61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/pdftoimage.rb', line 61

def exec(cmd, error = nil)
    output = `#{cmd}`
    if $? != 0
        if error == nil
            raise PDFError, "Error executing command: #{cmd}"
        else
            raise PDFError, error
        end
    end

    return output
end