the ">" character to save to an XML (when used in a shell Process() in Swift)

Started by philbond87, August 05, 2021, 11:08:51 PM

Previous topic - Next topic

philbond87

I'm trying to implement something like:
/usr/local/bin/exiftool -X aFile.jpg > /MyDir/someFile.xml

I'm running this from within a shell (actually a Process() in Swift).
I am able to do it without issue in another development environment but in Swift I'm having an issue with how to handle the ">" character.
No matter how I've tried to handle it – between single quotes, double quotes... various ways of escaping it... I can't get it to work. I keep getting a "file not found" error.

I would greatly appreciate any advice or suggestions.
Thanks!

StarGeek

Output redirection is a function of the shell/terminal.  It usually cannot be used when called from a non-shell environment like this.  Take a look at the -w (-TextOut) option or look for a way to capture the output in swift and write the file from the program.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

philbond87

Thanks, @Stargeek, I didn't realize that about redirection.
Capturing the data from process and saving it as and xml file (from within Swift) did just what I needed.