Jump to content

Command line tools and StdIO redirection to a file


PClough
 Share

Recommended Posts

Hi everyone!

I want to programmatically alter the structure of a large number of PDF which have different sizes and orientation, and come from different generators. To do this I need to be able to capture different parameters describing their layout.  I use a console tool called pdfInfo (part of the xpdf public domain suite) which provides me with everything I need. The idea is first to run pdfInfo against my pdf file redirecting the console's output to a text file. And then to load and parse the text file to get the parameters I need.  The only problem is that no output file is ever created.  I've looked through the forums and saw a number of threads loosely related to this but none of the suggested solutions (like using StdoutRead) has worked for me. I should say maybe that I'm running Win10.

So here's the code that doesn't work:

$pdfInfo = "f:\pdfinfo.exe"
$pdfTest = "f:\test.pdf"
RunWait(chr(34) & $pdfInfo & " -box " & $pdfTest & " > f:\log.txt", "", @SW_HIDE)

If you use in a console the command line: 

f:\pdfinfo.exe -box f:\test.pdf > f:\log.txt

it works perfectly.  But the piece of code above does not create the log.txt file. So any idea what I am doing wrong.  Thanks for any help!

 

 

Edited by PClough
Link to comment
Share on other sites

  • Developers

try:

RunWait(@comspec & " /c " & $pdfInfo & " -box " & $pdfTest & " > f:\log.txt", "", @SW_HIDE)

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

You may want to consider using the StdIn/StdOut functions to interact with the console process. That would enable you to eliminate the need to write and read a file.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...