PClough

Command line tools and StdIO redirection to a file

4 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Thanks a lot Jos.  Now it works and the parsing works fast too...

 

Share this post


Link to post
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.

Share this post


Link to post
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

  • Similar Content

    • aiter
      Console application - internal autoit error trap
      By aiter
      I am running my compiled application as a console application and need to prevent any internal errors from being displayed as a gui message, but rather display it as a console message only. An example of such an error would be a bad array reference (out of bounds).
      Does anyone know how to do this or point me in the right direction?
    • TXTechie
      Run batch file from AutoIt script with output to console
      By TXTechie
      I normally launch things silently, but now I want to launch a batch (.cmd) file and have it run as normal displaying it's standard output to the user. Whether I use ShellExecuteWait or RunWait, the command prompt window is displayed, but the output is blank (although I know that the batch file is processing normally because it also produces a log file).
      If this is because AutoIt is re-directing the standard I/O of the batch file/console window, is there a way I can bypass the I/O redirection?
      Thanks,
      TXTechie
    • Simpel
      [Solved] SciTE no functions working
      By Simpel
      Hi,
      I updated to the last version. Since then a lot of functions are not working.  For instance expanding abbreviation. My au3abbrev.properties are correct and abbrev.properties are including both import lines. The abbreviation is red but won't expand. Neither with space nor Ctrl+B.
      Debug to msgbox and console not working, list functions, jump to function, open include too.
      SciTE Jump works. Block and box comment too.
      I have the feeling all functions especially for autoit are not working.
      Any help? Regards, Conrad
    • leke
      Keeping the console window open after execution has finished
      By leke
      I have an app that rips .ts files, but I'm having a problem seeing the the error message ffmpeg is displaying because the console window closes right after the message is rendered. 
      If I manually type the equivalent command from the command line, the .ts file rips ok, so I'm guessing it's not the command itself that is the issue. 
      How do I get the console window to remain open when running it through my autoIt app? 
      Code in question...
       Thanks
      Source code.exe
    • MyUM
      How to control a console application ?
      By MyUM
      Hello, I have a console application that works with command line arguments which I don't have its source code, & I want to create a GUI for it to make it easier.
      My problem is how to make the GUI application calls the console application & handle its output results to display it in the GUI application  with a progressbar or somthing ?
      Please look at the "X265 Command Line Options"
      https://x265.readthedocs.org/en/default/cli.html
      MeGUI is only a GUI app for the cli apps :
      http://sourceforge.net/p/meguimodproj/code/HEAD/tree/MeGUI Mod/
      Help me please