Jump to content

Search the Community

Showing results for tags 'php telnet control'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Welcome to PHP Freaks
    • Announcements
    • Introductions
  • PHP Coding
    • PHP Coding Help
    • Regex Help
    • Third Party Scripts
    • FAQ/Code Snippet Repository
  • SQL / Database
    • MySQL Help
    • PostgreSQL
    • Microsoft SQL - MSSQL
    • Other RDBMS and SQL dialects
  • Client Side
    • HTML Help
    • CSS Help
    • Javascript Help
    • Other
  • Applications and Frameworks
    • Applications
    • Frameworks
    • Other Libraries
  • Web Server Administration
    • PHP Installation and Configuration
    • Linux
    • Apache HTTP Server
    • Microsoft IIS
    • Other Web Server Software
  • Other
    • Application Design
    • Other Programming Languages
    • Editor Help (PhpStorm, VS Code, etc)
    • Website Critique
    • Beta Test Your Stuff!
  • Freelance, Contracts, Employment, etc.
    • Services Offered
    • Job Offerings
  • General Discussion
    • PHPFreaks.com Website Feedback
    • Miscellaneous

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Location


Interests


Age


Donation Link

Found 1 result

  1. Hi guys, I'm at a standstill with this telnet script I'm trying to perfect. The scripts job is to interpret a command on the telnet connection and execute different commands based upon it. It's executed as a standalone script by the system, so no HTTP requests are involved. The script works for what I need, although after about a minute or so the script just freezes. Though the process still exists and I'm forced to re-open it. The server doesn't seem to hang at all, just the client side stuff. Hopefully I can get some insight as to why it hangs, thanks! <?php set_time_limit(0); //error_reporting(E_ALL); error_reporting(0); /* Get the port for the WWW service. */ //$service_port = getservbyname(86, 'tcp'); $service_port = 86; /* Get the IP address for the target host. */ $address = gethostbyname('removed'); /* Create a TCP/IP socket. */ $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if ($socket === false) { echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n"; } else { echo "Creating Socket... [OK]\n"; } echo "Attempting to connect to '$address' on port '$service_port'..."; $result = socket_connect($socket, $address, $service_port); if ($result === false) { echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n"; } else { echo "[OK]\n"; echo "Script Running...\n"; } $in = "Connect"; echo "Sending connect to server..."; socket_write($socket, $in, strlen($in)); echo "OK.\n"; //echo "Reading response:\n\n"; function probe($data) { $remote = $data; /* Code intentionally removed. Just saw variable and executed something based upon what it saw. */ if(strstr($remote, "rpi_reboot")) { shell_exec("sudo reboot"); } usleep('1000'); //10ms } $outnew = "0"; while ($out = socket_read($socket, 1000, PHP_BINARY_READ)) { echo $out; if($out != $outnew) { probe($out); $outnew = $out; usleep(1000); //To have a fast response time } else { } } /* When connection fails, kill all processes */ shell_exec("shell code here"); sleep(1); echo "Closing socket..."; socket_close($socket); echo "OK.\n\n"; sleep(1); exec("nohup sudo php /var/www/telnet.php > /dev/null 2>&1 &"); //Close process and open another exit(); ?>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.