Jump to content

Can RunShellScript execute a .bat file on FM server?


This topic is 2243 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi there,

I would like to be able to trigger FM server to execute a .bat file. For this purpose I use "Perform Script on Server" combined with SM RunShellScript ( "C:\dothis.bat" ; True ; 30 ), but nothing happens. The function returns ok (Executed Shell Command: ........) - no errors.

I can easily execute a system commands like echo, dir etc., but for some reason not a .bat file.

I have tried calling the cmd.exe prior to the .bat path, but it doesn't help.

RunShellScript( "cmd.exe /c C:\rename.bat" ; True ; 30 )

My goal it to run the .bat file on the server, not in the client - so I can't use Send Event...

Do anyone know if it's even possible? and how it's done?

 

Edited by thomas.brinch
Link to comment
Share on other sites

What does the batch file do?

Remember that everything you ask FMS to do runs in the security umbrella of the Windows "local system" account, unless you changed to a service account in the Services control panel.

If you have anything in the batch file that the 'local system' account can not do then it will fail.  You may want to beef up the batch file so that it logs its progress; that should help with debugging.

Link to comment
Share on other sites

Hi Wim,

I want to do different things like PDF split/merge with command tools like pdfToolkit and image manipulation with ImageMagick (also a command tool).

But for a start (just to test batch file execution) I am just doing copy and rename. The batch file is running fine when executed locally on the server.

It has two commands and looks like this:

copy "C:\Users\thomasbh\Documents\FM_stuff\A.txt" "C:\Users\thomasbh\Documents\FM_stuff\A copy.txt"

rename "C:\Users\thomasbh\Documents\FM_stuff\A.txt" "B.txt"

Edited by thomas.brinch
Link to comment
Share on other sites

If you can store these file in FileMaker Server's Documents or Temp folder, things will be easier. The server computer should normally not even be logged in with an OS user account, so your own user folder isn't the best place.

Link to comment
Share on other sites

I'm not sure which folders you are referring to. There's no Documents or Temp folders in the FileMaker Server installation directory or subdirectories:

C:\Program Files\FileMaker\FileMaker Server

and there's no "FileMaker user" account on the server - if it's a user Document folder?

Edited by thomas.brinch
Link to comment
Share on other sites

Okay. I overlooked that folder when I was checking, but unfortunally it doesn't work either. Maybe it's has something to do with permission, but both SYSTEM, Administrators and Users has Full control. 

Which user is FM scripting using?

 

Link to comment
Share on other sites

38 minutes ago, thomas.brinch said:

 

Which user is FM scripting using?

 

"Local system"

unless you changed it when you installed FMS.

Beef up the error trapping in your batch file so that you can see what error it reports.

Link to comment
Share on other sites

5 hours ago, Wim Decorte said:

Beef up the error trapping in your batch file so that you can see what error it reports.

How would I do that? I have narrowed it down to just one simple command (rename). I don't think the batch file causes the error - I think it's not executed at all.

Update: After a server restart I've found out that the batch file actually does execute the first time I call it, but it won't execute a second time or more. Neither will other batch files, but system commands will. If I stop FM server from admin module and starts it again then I can call a batch file once again, but no more.

No errors returned by SM RunShellScript.

That is very strange??

Edited by thomas.brinch
Link to comment
Share on other sites

Just to confirm & try narrow this down: you can have ScriptMaster run the bat file once only (until you restart FMS), but the plugin itself continues working - if you call any other function except the one to run your bat file, it works? Can you run another bat file? No bat files at all but other ScriptMaster commands? Or is ScriptMaster "dying" altogether?

How is the ScriptMaster plugin installed on the server - manually or using the "Install Plug-In File" script step, as part of the server-side script?

Have you tried executing the bat file directly using a Schedule running a System-level script set up in FileMaker Server, to see if that behaves differently?

Link to comment
Share on other sites

Hi David,

Yes. ScriptMaster will only execute the bat file once - until I restart FMS. Both RunShellScript and other SM functions does continue working. I can call RunShellScript with any system command instead of a bat file and it will execute (like RunShellScript("dir C:\")).

SM plugin is installed manually on the server in C:\Program Files\FileMaker\FileMaker Server\Database Server\Extensions and enabled in the admin console.

I've just tried setting up a schedule on the server and here the bat file executes every time as supposed.

I've also tried to see if any processes is "hanging" or has a high CPU usage on the server when RunShellScript executes the bat file the first time, but it doesn't seem to be an issue.

Edited by thomas.brinch
Link to comment
Share on other sites

Thank you all for your input.

Unfortunately, I can't find the problem with this SM plugin function - so for now I'm switching to the BaseElements plugin, which also is freeware and has similar functions. Now I can run my batch files from anywhere on the server as many times as I like :-D

I'd rather keep the number of plugins to a minimum, so if anybody out there had success running batch files on FMS (Windows) more than once with the SM plugin, please post it here. Maybe I'll give it another try then.

Edited by thomas.brinch
Link to comment
Share on other sites

Thanks for that info - if it works with the BE plugin, that would certainly indicate that there's something wrong with the ScriptMaster plugin itself. It would be interesting to hear from 360Works in this one... Did you report the error directly to them, send the log files, etc?

Link to comment
Share on other sites

Proficiency?  a lot more people know the OS commands than the equivalent Groovy...  I know, I'm one of them :)

I would do this through the BE plugin with VBscript or PowerShell syntax since it would allow me to do error trapping and handling in my familiar way.

Link to comment
Share on other sites

I get that Wim, and that is a good reason.

But not sure why using ScriptMaster to run a batch file, when it requires managing Java too, whereas BE does not. Using SM to run actual Groovy code would seem to be a better use of the available tech....

I would love to get more help on writing those other formats too, as its not easy to quickly find your way.. I learned AutoIt for the reason that there 'appears' to be a greater number of examples form which to learn.

Link to comment
Share on other sites

23 hours ago, john renfrew said:

But not sure why using ScriptMaster to run a batch file, when it requires managing Java too, whereas BE does not.

Agreed....

A few of us have proposed walk-in workshops in the vendor area of Devcon where we could show some of this stuff, together with server configs etc...  I really wish we could convince FMI to buy into it.

 

Link to comment
Share on other sites

This topic is 2243 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.