Skip to main content
Question

How do I run a script using a bat file and let User to input information before run the script

  • July 27, 2023
  • 4 replies
  • 8723 views

pushpa
Contributor
Forum|alt.badge.img+9

I have a FME 2022 Script that run against an Oracle Database and extract list of boundaries and output on to a FGDB. I would like to let User to run the script using a bat file, rather than intervene with the Script on FME workbench. I have a list of boundary IDs on an Excel that attached to the script then User can extract boundaries on the excel sheet. But I would like User to extract any boundaries begins with boundary ID ie: "AA-X-BB"

I would like some help to understand how to write the script that the bat file extract all the boundaries begins with my ID rather than a single boundary.

Any help would be appreciated.

thanks

Pushpa

4 replies

ryanatsafe
Safer
Forum|alt.badge.img+11
  • Safer
  • August 2, 2023

You'll want to use the set command.

Β 

From https://commandwindows.com/batch.htm:

Β 

You can also interact with a user and ask that data be entered. The old DOS had a "Choice" command for very limited interaction but that has been superseded in Windows XP/Vista by the more versatile "set /p". The syntax is:

set /pΒ variable= [string]

"Variable" is the name of the variable that will be assigned to the data that you want the user to input. "String" is the message that the user will see as a prompt. If desired, "string" can be omitted. Here is an example that asks the user to enter his or her name:

set /p name= What is your name?

This will create a variable %name% whose value is whatever the user enters. Note that the user must press the "Enter' key after typing the input.

Β 

Combine this with the Batch Processing Method 1: Command Line or Batch File article.

Β 

The important thing to keep in mind is that fme.exe is no longer included in the PATH environment variable, so you'll have to use an absolute path to fme.exe

Β 

You will need to publish a parameter in the workspace to receive the boundary name, and then use that in a Tester or a where clause on the reader.

Β 


pushpa
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • August 2, 2023

You'll want to use the set command.

Β 

From https://commandwindows.com/batch.htm:

Β 

You can also interact with a user and ask that data be entered. The old DOS had a "Choice" command for very limited interaction but that has been superseded in Windows XP/Vista by the more versatile "set /p". The syntax is:

set /pΒ variable= [string]

"Variable" is the name of the variable that will be assigned to the data that you want the user to input. "String" is the message that the user will see as a prompt. If desired, "string" can be omitted. Here is an example that asks the user to enter his or her name:

set /p name= What is your name?

This will create a variable %name% whose value is whatever the user enters. Note that the user must press the "Enter' key after typing the input.

Β 

Combine this with the Batch Processing Method 1: Command Line or Batch File article.

Β 

The important thing to keep in mind is that fme.exe is no longer included in the PATH environment variable, so you'll have to use an absolute path to fme.exe

Β 

You will need to publish a parameter in the workspace to receive the boundary name, and then use that in a Tester or a where clause on the reader.

Β 

thank you!


pushpa
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • August 13, 2023

You'll want to use the set command.

Β 

From https://commandwindows.com/batch.htm:

Β 

You can also interact with a user and ask that data be entered. The old DOS had a "Choice" command for very limited interaction but that has been superseded in Windows XP/Vista by the more versatile "set /p". The syntax is:

set /pΒ variable= [string]

"Variable" is the name of the variable that will be assigned to the data that you want the user to input. "String" is the message that the user will see as a prompt. If desired, "string" can be omitted. Here is an example that asks the user to enter his or her name:

set /p name= What is your name?

This will create a variable %name% whose value is whatever the user enters. Note that the user must press the "Enter' key after typing the input.

Β 

Combine this with the Batch Processing Method 1: Command Line or Batch File article.

Β 

The important thing to keep in mind is that fme.exe is no longer included in the PATH environment variable, so you'll have to use an absolute path to fme.exe

Β 

You will need to publish a parameter in the workspace to receive the boundary name, and then use that in a Tester or a where clause on the reader.

Β 

Hi Ryan,

Thanks for the information provided, it was very useful. However I found another way to select all smaller boundaries within Larger boundaries rather than inputting the individual IDs by User.

Β 

Now, I would like to User to rename the output FGDB name every time they run the FME script using the batch file.

I have created User Parameter called "NAMEFGDB" then linked with the "Writer". When I run the script using workbench or quick translator it prompt and I can change the FGDB name.

However when I run using the bat file, even though I type the new name for the FGDB, it still writes out to Default database name.

Β 

My Batch file is as below.

@echo ## Start translation ##

Β set /p NAMEFGDB=type fgdb name:

"C:\\Program Files\\FME\\FME2022-1-2\\fme.exe" D:\\GIS\\Data_extract_by_Area.fmw

@echo ## End translation ##

pause

Β 

Is there anything else I need to be doing to connect the FME script to batch file?

Β 

thanks,

Regards,

Pushpa


rjcragg
Safer
Forum|alt.badge.img+2
  • Safer
  • November 11, 2023

Hi Ryan,

Thanks for the information provided, it was very useful. However I found another way to select all smaller boundaries within Larger boundaries rather than inputting the individual IDs by User.

Β 

Now, I would like to User to rename the output FGDB name every time they run the FME script using the batch file.

I have created User Parameter called "NAMEFGDB" then linked with the "Writer". When I run the script using workbench or quick translator it prompt and I can change the FGDB name.

However when I run using the bat file, even though I type the new name for the FGDB, it still writes out to Default database name.

Β 

My Batch file is as below.

@echo ## Start translation ##

Β set /p NAMEFGDB=type fgdb name:

"C:\\Program Files\\FME\\FME2022-1-2\\fme.exe" D:\\GIS\\Data_extract_by_Area.fmw

@echo ## End translation ##

pause

Β 

Is there anything else I need to be doing to connect the FME script to batch file?

Β 

thanks,

Regards,

Pushpa

Sorry for the late reply. You'll have to add the parameter value to the FME.exe command:

"C:\\ProgramΒ Files\\FME\\FME2022-1-2\\fme.exe"Β D:\\GIS\\Data_extract_by_Area.fmw --NAMEFGDB %NAMEFGDB%