Keyboard Shortcuts
ctrl + shift + ? :
Show all keyboard shortcuts
ctrl + g :
Navigate to a group
ctrl + shift + f :
Find
ctrl + / :
Quick actions
esc to dismiss
Likes
Search
Locked
Execute a Windows Batch File from LogixNG or Script
#logixng
Team,
How can I execute a .bat file from either LogixNG or Jython script?
--
Many thanks in advance! Vinny DeRobertis ~ Apex, NC New York & Hudson Valley RR Windows 7 Pro / Java 11 / JMRI v5.7.7 Command Station: Digikeijs DR5000. Booster: Digikeijs DR5033 Interface: Samsung A7 10.4" Tablets/Fully Kiosk.
DCC/DMX Gateway: Pricom LLS. LocoNet Input Modules: Digikeijs DR4088LN DCC Output Modules: Digikeijs DR4018 / Yamorc YD8116. Sensors: Model Train Technology: DETECTOR-HO. Turnout Motors: MTB MP1 |
Try this bit of jython
Import java command = ¡°foo.bat¡± argument = ¡°something or blank" java.lang.Runtime.getRuntime().exec([command, argument]) Bob On Sep 28, 2024, at 1:50?PM, Vinny DeRobertis via groups.io <vinny.derobertis@...> wrote:¡ª Bob Jacobsen rgj1927@... |
Bob, I got the logix NG to call the script that calls the batch file however, the batch file only stays in it's loop for 1 iteration. When I run the batch file outside of JMRI it opens a DOS window and stays in its loop until I close the DOS window. When I call the batch file using the script, the DOS window does not open. The batch file runs and then immediately ends. |
I don¡¯t know much about Windows, so I¡¯m probably not the one to help with this unfortunately. And the following suggestion might not make sense.
Is there a command that will open another window from the command line? Maybe ¡°cmd.exe¡±, if I remember correctly? You could try using that as the ¡°command¡± in the script, with the batch file name as the ¡°argument¡± value. That might open the window, then start the batch file. Or it might not, as JMRI doesn¡¯t start from a command window. Sorry to not be able to be more helpful. Bob On Sep 29, 2024, at 2:31?PM, Vinny DeRobertis via groups.io <vinny.derobertis@...> wrote:¡ª Bob Jacobsen rgj1927@... |
Vinny, You cannot call a Jython script from outside of the JMRI/Java world. It would be helpful to know what you are actually trying to do. ?What does the bat file do? Dave Sand ----- Original message ----- From: Vinny DeRobertis <vinny.derobertis@...> Subject: Re: [jmriusers] Execute a Windows Batch File from LogixNG or Script #logixng Date: Sunday, September 29, 2024 7:26 PM ...rephrasing, how can I call a jython script x.py from within a windows/DOS batch file? |
Vinny, You can use an indirect notification from Windows using the LogixNG "File as flag" expression which can then run the Jython script. ?See? Dave Sand ----- Original message ----- From: Dave Sand <ds@...> Subject: Re: [jmriusers] Execute a Windows Batch File from LogixNG or Script #logixng Date: Sunday, September 29, 2024 9:14 PM Vinny, You cannot call a Jython script from outside of the JMRI/Java world. It would be helpful to know what you are actually trying to do. ?What does the bat file do? Dave Sand ----- Original message ----- From: Vinny DeRobertis <vinny.derobertis@...> Subject: Re: [jmriusers] Execute a Windows Batch File from LogixNG or Script #logixng Date: Sunday, September 29, 2024 7:26 PM ...rephrasing, how can I call a jython script x.py from within a windows/DOS batch file? |
¿ªÔÆÌåÓýVinny, Can you show us the batch file you are trying to run? Daniel On 2024-09-29 20:31, Vinny DeRobertis
wrote:
|
It¡¯s a bit brute force, but you could write a JMRI script or LogixNG that calls your .bat file every four seconds.
Bob On Sep 30, 2024, at 9:50?AM, Vinny DeRobertis via groups.io <vinny.derobertis@...> wrote:¡ª Bob Jacobsen rgj1927@... |
Am 30.09.2024 um 15:50 schrieb Vinny DeRobertis:
When I run it from windows it continues to take a screen shot every 4 seconds until I close the DOS window but when I run it from Bob's script it takes 1 screen shot and ends.I get the screenshots until I quit JMRI. My script: import java java.lang.Runtime.getRuntime().exec(["C:/temp/screenshot.bat", ""]) I'm running Windows 10. Klaus |
update, I modified the .bat to only take 1 screen shot, not loop every 4 secs.
?
I got rid of the LogixNG and I'm just using a Jython script now.
The script cycles through all of my panels?and for each panel, it calls the .bat to take the screenshot.
This works great!
?
Now with one press of a button I can get a .jpg of each panel that I can copy over to my phone for review when I'm away from the layout.
Also, I plan to use this to compile a single .PDF that shows all of my panels so that I can easily share with others.
Attached script is in its infancy as it only calls 5 of my 58 panels.
?
I know there is a slicker way to loop but I am not that skilled in Jython.
Thanks again!
? |
Vinny, Here is a sample of getting all of the frames and then checking for the first part of the title.
Dave Sand ----- Original message ----- From: Vinny DeRobertis <vinny.derobertis@...> Subject: Re: [jmriusers] Execute a Windows Batch File from LogixNG or Script #logixng Date: Wednesday, October 02, 2024 1:44 PM update, I modified the .bat to only take 1 screen shot, not loop every 4 secs. ? I got rid of the LogixNG and I'm just using a Jython script now. The script cycles through all of my panels?and for each panel, it calls the .bat to take the screenshot. This works great! ? Now with one press of a button I can get a .jpg of each panel that I can copy over to my phone for review when I'm away from the layout. Also, I plan to use this to compile a single .PDF that shows all of my panels so that I can easily share with others. Attached script is in its infancy as it only calls 5 of my 58 panels. ? I know there is a slicker way to loop but I am not that skilled in Jython. Thanks again! ? Attachments:
|
to navigate to use esc to dismiss