Skip to main content
Solved

Is it possible to run a command line command in FME?

  • June 13, 2018
  • 5 replies
  • 715 views

Forum|alt.badge.img

I would like to run a simple command-line command in FME and output the text to an excel table.

I want to run

taslklist /s SERVERNAME /fi "ArcSOC*" > c:tasklist.txt

...and then send the results into other transformers.

How would I do this?

Best answer by redgeographics

Yes, the SystemCaller will do that

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

redgeographics
Celebrity
Forum|alt.badge.img+59
  • Celebrity
  • 3700 replies
  • Best Answer
  • June 13, 2018

Yes, the SystemCaller will do that


takashi
Celebrity
  • 7843 replies
  • June 13, 2018

Yes, the SystemCaller will do that

Agree. The SystemCaller can be used here effectively.

 

Just be aware that the SystemCaller itself won't read the file created by the command. If you intend to use contents of the text file written by the command in the subsequent processes in the workspace, you will have to write the result into a temporary file then read back it with another transformer, such as the AttributeFileReader or the FeatureReader.

 

The TempPathnameCreator is convenient to create a temporary file path.

 

 


Forum|alt.badge.img

thanks for the advice. I am having trouble creating the temporary file to store the results of the commandline command. I have created a TempPathCreator and see that the attribute has been filled with a path. How do I read the temporary file with the AttributeFileReader? I have set the Source Filename to the attribute Temppath from the TempPathCreator and changed the encoding to DOS Latin.-1 but nothing is read.


takashi
Celebrity
  • 7843 replies
  • June 13, 2018

thanks for the advice. I am having trouble creating the temporary file to store the results of the commandline command. I have created a TempPathCreator and see that the attribute has been filled with a path. How do I read the temporary file with the AttributeFileReader? I have set the Source Filename to the attribute Temppath from the TempPathCreator and changed the encoding to DOS Latin.-1 but nothing is read. 

The TempPathnameCreator creates a temporary file path and save it into a feature attribute called "_pathname" by default, so you can construct the command line using the attribute value and set it to the SystemCaller. e.g.

 

"blablabla > "@Value(_pathname)""
You can then set "_pathname" to the "Source Filename" parameter in the subsequent AttributeFileReader to read the file.

 

If the file wasn't created anyway, set the "Exit Code Attribute" parameter in the SystemCaller to check if the exit code indicates 'success'.

 

Note: The temporary file will be removed automatically when the translation has completed. If you need to keep the file, specify an appropriate file path instead of the temporary file path. 

 

 


Forum|alt.badge.img
The TempPathnameCreator creates a temporary file path and save it into a feature attribute called "_pathname" by default, so you can construct the command line using the attribute value and set it to the SystemCaller. e.g.

 

"blablabla > "@Value(_pathname)""
You can then set "_pathname" to the "Source Filename" parameter in the subsequent AttributeFileReader to read the file.

 

If the file wasn't created anyway, set the "Exit Code Attribute" parameter in the SystemCaller to check if the exit code indicates 'success'.

 

Note: The temporary file will be removed automatically when the translation has completed. If you need to keep the file, specify an appropriate file path instead of the temporary file path. 

 

 

That worked super! thanks