OK, that radically complicates things. However you still have multiple options.
First off, is the server a Mac? There are other options for executing commands on a remote Mac.
Secondly, even if you do need to use SSH, you should shy away from logging in as root. There's nothing in this command that requires root-level privileges.
Thirdly, even if you do use ssh there's no absolute requirement to use Terminal.app - you should look at setting up private keys on the server, which will allow you to log in via SSH without needing an interactive password.
Fourthly, even if you do decide you need to use Terminal.app, your code is wrong 🙂
The issue is what 'do script' returns. Looking at the app's dictionary you see:
do script (verb)Runs a UNIX shell script or command. (from Terminal Suite)
set theResult to do script text ¬
in tab, window or anything
tabThe tab the command was executed in.
Note the result is the tab that the command was executed in. It's not the output of the last command executed in that window - it's a reference to the tab. You have to query that tab to find out what content is in its widow, and process that text to find the output of your command.
Your best hope here is that the server is a Mac and you can use Remote Apple Events to target the remote system
tell application "System Events" of machine "epcc://ip.of.remote.machine"
set remoteProcessList to do shell script "ps -A"
end tell
if remoteProcessList contains "httpd" then
-- Apache is running
end if
Note that I've also taken a slightly different approach, which is to have the shell script just grab the process list and use AppleScript logic to determine if httpd is running - that avoids the whole issue with grep's output if the text doesn't exist.