Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

I try to use the powershell from windows in "Run shell script", because I want to do more on the system than cmd.exe is able to handle.

I tried a modified version of "Rund shell script" where I replaced the cmd.exe by powershell.exe, or used the original script where I send a common like "powershell mode" but I don't get any results back.

Filemaker always hangs.

when I send the commands by Run from Start button and then it works but not in Filemaker.

Any ideas why this does not work?

Markus

  • 2 months later...
Posted

FWIW, I'm trying

RunShellScript( ""powershell.exe -ExecutionPolicy Unrestricted -File … ;"true";0)

and it works (YAY), in that it runs the .ps1 file I specify, but when I run it as a schedule on the server, the schedule locks (BOO) with status "RUNNING" and the client by that schedule name persists. Previously when schedules lock like that I have to take the whole DB offline to fix that.

I'm going to try "false" instead of true to see if I can work round it, and I'll post back if that works at least.

Posted

(limited) SUCCESS!

http://stackoverflow.com/questions/4745895/powershell-process-hanging-when-called-from-java-application

suggested to me adding "process.getOutputStream().close();¶" to the registergroovy for RunShellScript might do the trick. And indeed it does, for cases where you DON'T wait for the results (the 2nd parameter is "false") the powershell process quits OK if you add an extra line like this

inputStream.close();¶

errorStream.close();¶

process.getOutputStream().close();¶

return "Executed shell command: " + command;¶

I've not got it to work with the waiting for the result "true" option yet which I'd ideally like to do. In practice the shell is never going to take longer than a few seconds, so I can just sleep/wait before continuing what I am doing

Posted

MORE - adding the extra line in this bit of code appears to work for "true" waiting for output cases


 try {¶

  process.getOutputStream().close();¶

  if( process.waitFor() == 0 ) { //Successful¶

   stdoutThread.join(); //Wait for all output to be read¶

   return stdout.toString();¶

  } else { //Error when running command¶

   stderrThread.join(); //Wait for entire error message to be read¶

   throw new RuntimeException( stderr.toString() );¶

  }¶

} catch( InterruptedException e ) {¶

  throw new RuntimeException("Process was interrupted; error output is: " + stderr.toString() );¶

}¶

I haven't yet tested if non powershell invoking cmds mess up with these extra commands.

This topic is 4579 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
×
×
  • Create New...

Important Information

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