Author Topic: stay_open and its messages  (Read 819 times)

nfourteen

  • Newbie
  • *
  • Posts: 2
stay_open and its messages
« on: December 30, 2016, 01:59:56 PM »
I have two related questions.

1) I am executing Exiftool using -stay_open True -@ - from PHP using Symfony's 3.2 Process component and writing commands to stdin using InputStream. Currently I build an array of commands and write those commands to the InputStream (each followed by a new line char) and then a single -execute command. This works for reading metadata and I get back an array of arrays. However, for writing metadata, each image is getting the same metadata - the last tag values. I'm assuming this relates to -TAG[+-]=[VALUE] documentation "Notes" section "1) Many tag values may be assigned in a single command...". My question is, am I misinterpreting the -execute functionality - should I be using it as if I were entering single commands on the command line and pressing enter instead of batch writing commands and using only one -execute.

2) I've encountered some weird behavior where Symfony's 3.2 Process component getErrorOutput() method is catching the messages from exiftool where it reports "n image files read" or "n image files updated". The {ready}\n message is returned on stdout and I've used -q to suppress the "image files" messages, but that is also suppressing the {ready}\n message. I suspect it might have something to do with the Process components callback function changing context, but before I go that route I wanted to clarify exiftool's /usr/bin/perl script. I'm new to Perl and trying to understand line 1710 elsif. Are messages from exiftool using -stay_open True -@ - being returned on stderr?

Phil Harvey

  • ExifTool Author
  • Administrator
  • ExifTool Freak
  • *****
  • Posts: 11830
    • ExifTool Home Page
Re: stay_open and its messages
« Reply #1 on: December 30, 2016, 02:38:53 PM »
My question is, am I misinterpreting the -execute functionality - should I be using it as if I were entering single commands on the command line and pressing enter instead of batch writing commands and using only one -execute.

The functionality of -execute is exactly as if a separate command has been executed (with minor exceptions as mentioned in the docs).  So exiftool ARGS1 -execute ARGS2 is exactly the same as exiftool ARGS1 followed by exiftool ARGS2.

Quote
Are messages from exiftool using -stay_open True -@ - being returned on stderr?

They are the same as when you aren't using -stay_open.   They go to stderr instead of stdout under some circumstances (eg. to avoid messing up structured output).

If you want to use -q and still receive the "{ready}" messages, add a -echo3 or -echo4 to echo your desired "{ready}" message to stdout or stderr.

- Phil
...where DIR is the name of a directory containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

nfourteen

  • Newbie
  • *
  • Posts: 2
Re: stay_open and its messages
« Reply #2 on: December 30, 2016, 05:17:49 PM »
Excellent! Thank you for such a quick response!