02-28-2013 01:57 PM
I have a piece of code as shown in the attached jpg. And I have it deployed just as shown, without the error cluster being wired. I use this piece of code to ping a server to see if it's there, meaning to see if it responds with a correct ping response. If so, I then move forward with writing a data file to that server that I write every half hour for days or weeks at a time. If the ping response is not correct, I simply go on and return one half hour later with even a larger (appended) data file to write. My main intent is to not have my code sit and wait, trying to write a file to a server that might not be there...
I've used this same code and technique for years without fail. Until recently. When it did finally fail, I got the worst of all possible outcomes where the ping command itself caused my code to hang with error messages I will provide shortly. And I'm hoping someone can tell me what would even cause a message like those below in the first place... The entire goal of using this ping of the server was to avoid having the "write file" command get held hostage by the server not being there... But if the ping command itself causes the code to put up error messages (and no one is there to monitor this typically) then that constitutes a situation where my cure became my problem.
See in the jpg where I use
ping -w 200 -n 1
followed by the name or IP address of the server. (that's what comes out of the "ping" control you see in the jpg).
The -w 200 modifier is a 200 ms timeout to wait.
The -n 1 is the number (1) of echo requests to send.
When this code fails, it puts up, in sequence, four messages like the one below. Note that this code is running from an executable that would be found on this Windows XP machine at
C:\Documents and Settings\xxxxuser\My Documents\my_executables\
The first of the four messages, each of which you have to click OK to to see the next one, is as follows.
The file C:\Documents and Settings\xxxxuser\My Documents\my_executables\-w could not be opened. No application was found to open that type of file
The second message is identical to the above except the "-w" is replaced by "200" (without the quotes).
Same with the third message except the "200" is now replaced by "1" (without the quotes).
Same again with the fourth message except the "1" is now replaced by the full name of the server, eg., "myserver.abc.com" (without the quotes).
Clearly the System Exec.vi (see that in jpg) is parsing up the ping command, but skipping over the "-n" component(???), and it thinks it's supposed to try to open some non-existent file at the same file location as the executable that is executing my code.
I get this result rarely so it's hard to figure out what's going on. Anyone have any ideas what might cause such an error and any hints on how to prevent this show stopping error from occurring??? Do I perhaps just need to practice better programming and wire the error cluster on System Exec.vi???
Any thoughts or help would be much appreciated... thanks.. bob..
02-28-2013 03:22 PM
The help suggests: "To use a command that must be executed directly from a command prompt window, insert cmd /c before the command."
That might fix it for you, or you could try specifying the working directory to the correct path to the command prompt.. something like %windir%\system32
02-28-2013 04:14 PM
But can you even suggest what might be going on to prompt what appears to me to be a non-sensical question, that being,
The file C:\Documents and Settings\xxxxuser\My Documents\my_executables\-w could not be opened. No application was found to open that type of file
What could prompt the System Exec.vi to ever want to suggest that some path ending with portions of the parsed ping command is a path to a file that something (?) somehow (?) is supposedly asking to be opened???
If I could understand what prompts such a strange message, I could perhaps know what to do to keep it from happening. Any thoughts??? thanks... bob...
03-01-2013 12:48 PM
It appears to me that your ping command is getting mangled on its way to the command shell, like something is interrupting it or trying to run at the same time.
When it says the executable cannot be opened, I believe that is because it's trying to process that character or string as its own separate command, instead of as a flag of your ping command.
I don't know why that would happen or what outside program could be interfering with your call to the command shell.
I do think that Wart's suggestion is a good one: the cmd /c part should send the command through a slightly different channel that may preven this interference.
03-04-2013 12:36 PM
So are you guys saying to run
cmd /c ping -w 200 -n 1
Like that???
thanks... bob...