It seems that it would be very hard to do direct shell access through a server side language such as PHP. It would require tons of updates, persistent variables and other hairy things. If all you want to do is execute a single command through the shell, that would be another thing. There's probably a way to send commands to the server you're trying to reach through ssh's or telnet's commandline, read up on those manpages about that. Then use this knowledge to send a single command using exec like you suggest. I doubt there's any other way to do this, but I could be wrong.