Using popen() to Read the Output of the Unix 'who' Command
Administrators currently logged on to the server
$ph = popen( "who", "r" )or die( "Couldn't open connection to 'who' command" );
$host="demo.com";
while ( ! feof( $ph ) ) {
$line = fgets( $ph, 1024 );
if ( strlen( $line ) <= 1 ) {
continue;
}
$line = preg_replace( "/^(\S+).*/",
"$1
\n",
$line );
print "$line";
}
pclose( $ph );
?>