Skip to main content
Question

FME Executing system commands

  • 24 January 2013
  • 3 replies
  • 27 views

Hi All,

 

 

I have a FME Workbench which runs every night via a scheduled Windows process which looks at a MapInfo TAB file which has been edited during that day by users.

 

 

It QAs the data and then spits out the "good" elements to a Production area for use by the orginisation the following day.  This workbench works fine.  We can run it manually and the process executes perfectly.

 

 

The problem is that over the past few nights the process has failed to execute because it fails to read the TAB from the editing directory.  We have checked the system logs and it seems that (different) users have left their computers on overnight with the file open...

 

 

My question is (finally) can FME execute any "system" commands?  We obviously want to kick any users off who have a lock on these files and I just wanted to know if we can write it into the workbench.  There is some talk in the office here about using some Python to do it, but I have only dabbled in it and am not really sure of it's capabilities.  At this point it looks like that's the way we'll be heading.
The SystemCaller may give you some options. Though it may be more practical to deal with the problem at source by forcing the local machine to shut down or close active tasks at a scheduled time...
Thanks Dave.

 

 

I have the programmers writing a simple .EXE ATM to do just this.

 

 

I had no idea FME could do this.  I've only been using Workbench for 12 months but this product keeps amazing me!
You can do it in the batch file the you call through scheduler to run fme we have lots that do that sort of thing. For example here is a bit from a bat file we use:

 

 

::Run spatial parcel building before compress for occupancy procedure

 

fme.exe "C:\\GISprojects\\FME\\Daily\\Spatial Joins\\Spatial_parcel_BUILDINGS.fmw"

::Rename directory if it processed in morning

 

PUSHD C:\\GISProjects\\NaturalAreas\\ProcessedDataFiles

 

If EXIST %date% ren %date% %date%_AM"

 

POPD

:: Create dated directory

 

:: added only if the shape files exist in the directory MKDIR "C:\\GISProjects\\Road_patrol\\ProcessedDataFiles\\%date%"

 

echo Road Patrol Import Started - %date%  >> C:\\GISProjects\\Road_patrol\\ProcessedDataFiles\\%date%\\Import_Summary.txt

::Mark

 

If EXIST C:\\GISProjects\\Road_patrol\\Data_CheckIN\\MARK\\ROAD_PATROL_POINT.shp MKDIR "C:\\GISProjects\\Road_patrol\\ProcessedDataFiles\\%date%"

 

If EXIST C:\\GISProjects\\Road_patrol\\Data_CheckIN\\MARK\\ROAD_PATROL_POINT.shp fme.exe "C:\\GISProjects\\Road_patrol\\FME\\Road_Patrol.fmw" --SourceDataset_SHAPE "C:\\GISProjects\\Road_patrol\\Data_CheckIN\\MARK\\*.shp" --ATTR_LIST VEHICLEID,Vehicle1,OPERATOR,MARK

 

If EXIST C:\\GISProjects\\Road_patrol\\Data_CheckIN\\MARK\\ROAD_PATROL_POINT.shp echo Import Mark's Road Patrol - %TIME%   >> C:\\GISProjects\\Road_patrol\\ProcessedDataFiles\\%date%\\Import_Summary.txt

 

 

We have jut started changing our bat files over to python scripts that you run through a scheduled task. You can do a lot more using python so I would use it over bat to execute system commands. As a start this is how you call your fme workbench in python:

 

 

import os

 

os.system ('fme.exe "C:\\GISprojects\\FME\\Daily\\Cityworks\\Cityworks_Workorders.fmw"')

 

 

Reply