gardarog
Member
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?
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: