• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

asp: reacting to output on page

rh71

No Lifer
I have an ASP page with a function (that's written in an include) that grabs output from another server and displays it right on the ASP page using response.write. The function uses 'psexec' to interact with a command prompt of another server. PSEXEC is a command-line remoting executable that is capable of bringing output back to your machine.

What I want to do is depending on the output that comes back on the ASP page, I want it to display something to the effect of success or failure.

Right now, it displays "OK: completed successfully" or "ERROR: 0x222 name not found" just fine on the ASP page. I want to display more depending on either of those. If it's the latter, I'd display "failure" on the page.

I am not savvy enough to grab this output from the function and read/react to it using something like inStr(). The output is obviously within the response.write(myfunction()). I've tried referring to the var in the function itself but inStr() doesn't seem to read it correctly and thus doesn't react with either of my conditions - no errors either. Is there some other method of doing this? Am I on the right track here? Can you write up a quick example of how it should be done?
 
The output of myfunction() is probably a string. So try something like this to start with:

string s = myfunction();
s = s.Replace("OK: completed successfully", "My custom message");
s = s.Replace("ERROR: 0x222 name not found", "Another custom message");
Response.Write(s):

If the match string isn't found Replace() returns the original string, so you can add additional lines for other messages you want to replace. There's a performance cost to this, and there may be better ways to do it based on more knowledge of how psexec() works, but this is a start.
 
Back
Top