stdout as opaque dataset, how does it work?

Post Reply
bkromer
Member
Posts: 99
Joined: Thu Jul 11, 2019 10:41 am

stdout as opaque dataset, how does it work?

Post by bkromer »

With the new version of Switch it's possible to run an executable with "Execute command" and have the stdout written to the file as opaque dataset.
This is documented here:
https://www.enfocus.com/manuals/UserGui ... mmand.html

I would like to use that feature and wrote a simple.exe which outputs "42" when ran successfully. Its made in python3 and uses the sys.stdout.write("42") function.
example in win cmd:
stdout.png
stdout.png (16.74 KiB) Viewed 4906 times
Now to test this I made a simple flow.
Bildschirmfoto 2021-12-09 um 17.21.50.png
Bildschirmfoto 2021-12-09 um 17.21.50.png (26.72 KiB) Viewed 4906 times
In the options of the "Execute command" module I specified the simple.exe to run without any arguments.
The output should be an updated version of the inputfile and the Stdout should be attached to the inputfile as opaque dataset with the Name "s".
Also the "exit code" is being ignored.
Now the file runs to the success route but the dataset "s" is not accessible and has no value. Why is that?
at [Metadata.Text:Dataset="s",Path=""]
Attachments
Bildschirmfoto 2021-12-09 um 17.22.35.png
Bildschirmfoto 2021-12-09 um 17.22.35.png (88.37 KiB) Viewed 4906 times
Benjamin
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: stdout as opaque dataset, how does it work?

Post by jan_suhr »

Opaque dataset is just a link to a file (could be any file type) that Switch keeps in its internal folders. It is a clever way to keep a file together with a job. To get it back as a file or as in this case save it out to be able to read it you have to use the Export metadata configurator. It will save out the file in the Opaque dataset to the outgoing log connection.

This is only possible if you have the Metadata module.
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
bkromer
Member
Posts: 99
Joined: Thu Jul 11, 2019 10:41 am

Re: stdout as opaque dataset, how does it work?

Post by bkromer »

Hey jan,
when I use the "Export Metadata"-element it gives me three ways of exporting the opaque Dataset.
File, File+protocoll and protocoll. Protocoll gives me a *.opaque file.

I can then read the opaque file and my stdout is written to it. So far so good.

Is there a way of doing this programmatically I just read about the function "job.getDataset(DatasetStdout, AccessLevel.ReadOnly)"
As documented here https://www.enfocus.com/manuals/Develop ... ation.html

But cant get it to work.

My goal is to read the dataset and sort the job-file wich is a .xml based on the information in the dataset. Therefore I need both the information of the dataset and the XML itself. Any hints?
Benjamin
jan_suhr
Advanced member
Posts: 586
Joined: Fri Nov 04, 2011 1:12 pm
Location: Nyköping, Sweden

Re: stdout as opaque dataset, how does it work?

Post by jan_suhr »

Can't you do two exports, one with the Opaque and one with the XML-dataset and then combine them?
Jan Suhr
Color Consult AB
Sweden
=============
Check out my apps
Arthur
Member
Posts: 113
Joined: Sat Sep 09, 2017 11:58 pm
Location: Yateley, UK

Re: stdout as opaque dataset, how does it work?

Post by Arthur »

I recently had a similar case where the Stdout was needed accessed via Switch, but the opaque datasets are not accessible directly in Switch due to the format (it can be anything).
So the lovely support suggested 2 workarounds:
1. exactly as Jan described above
2. use the "Run Command" APP from the AppStore instead of the Native Execute Command, which is free and saves the StdOut and StdErr to Private data, where it can easily be read from.

I am finding the 2nd method much more efficient.
bkromer
Member
Posts: 99
Joined: Thu Jul 11, 2019 10:41 am

Re: stdout as opaque dataset, how does it work?

Post by bkromer »

Thank you both. I will use the free App Run Command. :D
Benjamin
Post Reply