Skip to main content

I have a power shell script, which retrieves data and saves it to a Jason file. I can run this with a Windows schedule task.

 

I have successfully created a FME project which retrieves that data and populates a database table.

 

Now we want to look at the possibility of executing the power shell script, within the FME project. I have tried this with a SystemCaller but it does not work.

 

Therefore I tried to simplify it. I have created a batch file that appends the current date time to a text file. I have tried using this instead, but when I run the workspace, the text file is now updated scratch that is not updated.

Note, I have tried it with the full path as well as just the name of the batch file.

 

FMECan anyone advise?

 

Thanks

 

Can you try with the full path in the command line?


I was annoyed at the screenshot because if it had been taken 10 minutes earlier, it would have shown the full path. So unfortunately I have already tried this.


Try the following command line for batch files:

cmd.exe datetime.bat

 For Powershell:

powershell.exe datetime.ps1

 


I was annoyed at the screenshot because if it had been taken 10 minutes earlier, it would have shown the full path. So unfortunately I have already tried this.

Okay, the full path is definitely the way to go. When you try that, do you see any error messages in the translation log?

 

Does the batch file run properly from the command line?


Try the following command line for batch files:

cmd.exe datetime.bat

 For Powershell:

powershell.exe datetime.ps1

 

I have tried using cmd.exe. Both attempts used the full path for the batch file. I have tried with datetime.bat in quotation marks and without. However unfortunately it is still not working.


I have tried using cmd.exe. Both attempts used the full path for the batch file. I have tried with datetime.bat in quotation marks and without. However unfortunately it is still not working.

Be careful if you have spaces anywhere in the command line, the SystemCaller is a bit weird about them, see also the documentation. 

Here's a working example:

""c:\temp\date and time.bat" ABC"

This calls the batch file "date and time.bat" with the command line parameter "ABC". Note the extra set of double quotes around the entire command.


I have tried various options, as many permutations as I can think of. With quotation marks and without. Just the name of the batch file, the name of the batch file, preceded with "cmd ", with no quotation marks, quotation marks around the whole line or just around the batch filename.


I just made my own datetime.bat ran it through the SystemCaller with no issues. Here is what I have:

 

SystemCaller_datetime_batLOG:

SystemCaller: Executing `C:\\tmp\\fstmpsc_akboyd\\datetime.bat'

CMD.EXE was started with the above path as the current directory.

UNC paths are not supported. Defaulting to Windows directory.

C:\\Windows>echo Tue 08/29/2023 11:26:30.41 1>>C:\\tmp\\fstmpsc_akboyd\\devtracker.log 

 

Result:

output_from_systemcaller_bat 

If you are using windows supported paths it should work in theory.......is your .bat executing from a UNC path? Or is the code in the .bat using a UNC path? Any UNC path will have to be changed and mostly likely converted to a network drive path (map to T: for example).

 

In the FME logs of the workbench, when your systemcaller is executing.....what do the messages say? Does it say the .bat is executing?


Thanks, that solved my initial problem-the batch file is now working.

 

I did not realise I needed a creator transformer first! The power shell script is not working yet but that's down to some antivirus software on the server.


Unfortunately, I have another problem.

 

The workspace now successfully executes the power shell script. The script retrieves active directory users and the results are output to a Json file. The problem I am finding, is that if I bring too many users back, it results in an empty Json file. We discovered this when we tried to use FME to return a call ll the users.

 

Therefore, we had the idea of testing it by running it for all users begin with A, then A and B etc. When I did this, everything worked until I believe users begin with M. To cut a long story short, I discovered it was not particular letters that caused the issue but I believe the amount of data. This was because I could include problematic letters, if I dropped earlier letters in the alphabet.

 

I should emphasise that the problem only occurs when I tried to run the power shell script through FME. When I run the script, out with FME, the script runs correctly, even for all the users, which results in a file about 330 MB in size.

 

Any idea what could be the issue?


be carefull of merging different technology disiplines. It creates technical debt and becomes complicated to maintain in the long run. Why not create the same logic with the power of FME and, get rid of that old script?


Reply