Hi,
Can anyone tell me how to use telnet command inside php.
I tried this
$output = shell_exec('telnet loneqresdbu2.uk.db.com 9001');
echo $output;
But it is not outputting anything.
and also how do I close the telnet connection.
Regards
Sriram.S
using telnet inside php code
Moderator: General Moderators
Code: Select all
$fp = fsockopen('loneqresdbu2.uk.db.com', 9001);
// probably need to login
fwrite($fp, "username\n");
fwrite($fp, "password\n");
while ($line = fread($fp, 2048))
{
// do things with $line
}- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
srirams wrote:If the site is down the browser throws an error message in 30.
Instead can we just display
site is down.
Code: Select all
$fp = @fsockopen('loneqresdbu2.uk.db.com', 9001);
if ($fp) {
// probably need to login
fwrite($fp, "username\n");
fwrite($fp, "password\n");
while ($line = fread($fp, 2048))
{
// do things with $line
}
} else {
//return error
}