![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]()
|
New Here? Please read this important info!!!
![]() |
#1 |
Member
![]() ![]() Join Date: Jul 2015
Location: Egilsstadir
Posts: 23
|
Batch script executed from InTouch doesn't generate output
I've developed a simple batch script to test communications with a couple of ethernet devices one of our clients has out in the field.
The script pings a static IP address and prints the result to a text file. I've tested the script thoroughly, and it works like a charm. The script (e.g. ping14.bat) generates a text file (ping14result.txt) in it's containing directory, with a value to indicate if the ping was successful or not. I've made a network diagram in the client's Wonderware InTouch 10.6 SCADA application, which displays the various field devices, and has a button to check comms for each one. The button runs an action script, calling the batch script: StartApp "c:\bat\ping14.bat"; The button has a green indicator if the device responded to the ping, and a red blinking indicator if the device was unresponsive. I'm using a continuous FileReadMessage() built-in function in the window script to read the value contained in the text file generated by the .bat script to a Memory Message tag. FileReadMessage ("c:\bat\ping14result.txt",0,ping14result, 0); The indicator works fine, and returns the correct value from the text file to the message tag. HOWEVER: When the InTouch button is used to trigger the script, the script doesn't generate output. Let's say I delete the text file, ping14result.txt. I then go to the running InTouch application and use the button to run the .bat script. I get a flashing CMD prompt on my screen, so everything looks OK. I then go to the directory to check the .txt file, and there's nothing there. I've also tried adding "pauses" in the batch script before and after the result is printed to the text file, to make sure the problem is not due to the script not completing it's execution. pause @echo %result%> ping14result.txt pause And the result was the same. Now, if I double click the .bat file from windows explorer, everything works fine. The .txt file is generated if needed, and it's values overwritten if it's already in place. I've also tried running the .bat script by calling it from the command prompt and it runs fine. Now I'm wondering what could be causing this? I've tried removing the FileReadMessage() code from the window script, to make sure that WindowViewer isn't reserving the .txt files and preventing them from being overwritten, with no luck... ![]() Has anyone seen this kind of behaviour before? Last edited by gardarog; May 12th, 2017 at 06:47 AM. |
![]() |
![]() |
#2 |
Lifetime Supporting Member
|
You may try the WWDosCommand function instead of StartApp. The script function WWDosCommand, can be found in Wonderware Tech Support Script Function Library online or on the Knowledgebase CD.
Else I would rather use some network monitoring software. By experience constantly writing, reading and deleting files within InTouch scripts sooner or later cause problems. |
![]() |
![]() |
#3 |
Member
![]() ![]() Join Date: Jul 2015
Location: Egilsstadir
Posts: 23
|
Thanks xzen, I gave that ago earlier today, using the WWDosCommand to run the .bat script.
I even tried using the WWDosCommand instead of the .bat script to perform the ping and output to a text file, with little luck. There's something fishy going I here... Do you have experience working with outputs in this manner, and have you had better results? |
![]() |
![]() |
#4 |
Member
![]() ![]() Join Date: Apr 2009
Location: Kalieefornia
Posts: 659
|
I use the WWDosCommand to get the PC's IP address using a batch file. Basically:
ipconfig /all > ip.txt But then I have found that that file wont show up instantly and I had to use some condition scripting to poll for that file, then get the IP address out of it. |
![]() |
![]() |
#5 |
Member
![]() ![]() Join Date: Mar 2016
Location: Fl
Posts: 464
|
A couple of things to check for.
A .bat (batch) file isn't executionable by itself. It needs the command interpreter to interpret and execute the batch file. That happens by itself when you execute it from a dos prompt (because a dos prompt IS cmd.exe, the actual command interpreter in Windows). It might not happen from within InTouch. It depends on what the developers did. So to explicitly execute a batch file you can use cmd.exe /c batfile.bat. You can also explicitly specify the path to cmd.exe. Second thing to check is that the Intouch application is running under a specific user account. For your bat file to be able to actually write to the disc the Intouch user must have the rights to write to that directory. Third thing to check is to check that you are using absolute paths to the files. If you create a file make sure it's specified otherwise the file will end up in different directories depending on the working directory. That would be different when run from the command prompt or from within Intouch. Last edited by Pete.S.; May 12th, 2017 at 09:55 PM. |
![]() |
![]() |
#6 | |
Member
![]() ![]() Join Date: Jul 2015
Location: Egilsstadir
Posts: 23
|
Quote:
I changed my .bat script so that it would output the ping result like so: @echo %result%> c:\bat\ping14result.txt instead of: @echo %result%> ping14result.txt And that did the trick. Thank you all for your input, and you Pete for easing my headache! |
|
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
RSview SE and Visual Basic | SCAN.PLC | LIVE PLC Questions And Answers | 9 | May 29th, 2015 03:20 PM |
Generate Emails / Run Batch Files Based on WW Tag Values | five | LIVE PLC Questions And Answers | 2 | March 24th, 2014 08:37 AM |
UNIDRIVE 1405 Analog output help_AB pf 70 | MJC | LIVE PLC Questions And Answers | 45 | July 11th, 2012 07:37 PM |
Can any one write script / batch commands ?? | Sparki | LIVE PLC Questions And Answers | 2 | October 31st, 2008 04:48 PM |
InTouch Application Script Query | jaichains | LIVE PLC Questions And Answers | 7 | July 19th, 2006 08:37 AM |