Question

Return result in attribute with SystemCaller

  • 23 February 2018
  • 2 replies
  • 37 views

Badge

Hi everybody.

I try to recept the result of a cmd code used in a SystemCaller transformer :

In fact my SystemCaller works with my result (in this case : 3)

But in facts, the result is not saved :

What can I do for resolve this ?

Thank you for your help.


2 replies

Badge

The Exit Code will be returning the value of the ERRORLEVEL attribute that is created whenever you execute a command at the command line. For FIND, and exit code of 0 should mean "FIND Completed Successfully and at least one Match was Found"

It sounds like you want the actual results of the DIR that was piped into the FIND. That's a bit trickier, but here are some options:

1. Use a PythonCaller instead. This will allow you to populate an actual attribute on the feature with the results of the FIND. The downside of this is that you have to be comfortable with Python. Option 2 might be easier.

2. Write (redirect) the results of the FIND into a temporary file, and then read that file using the AttributeFileReader transformer. This is actually pretty simple to do, and won't require much change to your SystemCaller.

http://www.lagmonster.org/docs/DOS7/pipes.html

Just add something like `>c:\\temp\\findresults.txt` to the end of the command in the system caller.

That should write the results to a text file. Then read the text file with the AttributeFileReader. That will copy the contents of the text file into a new attribute on your feature.

If the command in the SystemCaller starts getting too big, create a batch file to run instead, and have the SystemCaller call the batch file. I often use an AttributeManager to create an attribute that contains all the contents of the batch file, followed by an AttributeFileWriter to create the batch file, then the SystemCaller to execute the batch file (which contains a redirect to create an output text file), and then an AttributeFileReader to retrieve the results of the batch file from the text file.

Here's an example of a batch file that will store the output of the command to a log file. :

@echo off

call :launch > c:\\temp\\@Value(_uuid)\\launch.log

goto:eof

:launch node c:\\temp\\@Value(_uuid)\\ec2.js goto:eof

Badge

The Exit Code will be returning the value of the ERRORLEVEL attribute that is created whenever you execute a command at the command line. For FIND, and exit code of 0 should mean "FIND Completed Successfully and at least one Match was Found"

It sounds like you want the actual results of the DIR that was piped into the FIND. That's a bit trickier, but here are some options:

1. Use a PythonCaller instead. This will allow you to populate an actual attribute on the feature with the results of the FIND. The downside of this is that you have to be comfortable with Python. Option 2 might be easier.

2. Write (redirect) the results of the FIND into a temporary file, and then read that file using the AttributeFileReader transformer. This is actually pretty simple to do, and won't require much change to your SystemCaller.

http://www.lagmonster.org/docs/DOS7/pipes.html

Just add something like `>c:\\temp\\findresults.txt` to the end of the command in the system caller.

That should write the results to a text file. Then read the text file with the AttributeFileReader. That will copy the contents of the text file into a new attribute on your feature.

If the command in the SystemCaller starts getting too big, create a batch file to run instead, and have the SystemCaller call the batch file. I often use an AttributeManager to create an attribute that contains all the contents of the batch file, followed by an AttributeFileWriter to create the batch file, then the SystemCaller to execute the batch file (which contains a redirect to create an output text file), and then an AttributeFileReader to retrieve the results of the batch file from the text file.

Here's an example of a batch file that will store the output of the command to a log file. :

@echo off

call :launch > c:\\temp\\@Value(_uuid)\\launch.log

goto:eof

:launch node c:\\temp\\@Value(_uuid)\\ec2.js goto:eof

This is a perfect answer thank you very much Ryan. I decided to create a temporary txt file and after keep the number in an attribute, I delete it with a SystemCaller.

 

 

Reply