Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8605607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:52:44+00:00 2026-06-12T02:52:44+00:00

I’m trying to control remote power switch by executing some php commands. There is

  • 0

I’m trying to control remote power switch by executing some php commands.

There is a telnet library which I’m using to make a telnet connection: http://www.soucy.org/project/cisco/source.php

My connect function looks like this:

public function connect() 
{
    $this->_connection = fsockopen($this->_hostname, $this->_port, $errno, $errstr, $this->_timeout);
    if ($this->_connection === false) {
        die("Error: Connection Failed for $this->_hostname\n");
    } // if
    stream_set_timeout($this->_connection, $this->_timeout);
    $this->_readTo(':');
    if (substr($this->_data, -9) == 'Username:') {
        $this->_send($this->_username);
        $this->_readTo(':');
    } // if
    $this->_send($this->_password);

    $this->_send(''); //blank space, because we need to press <Enter> for the second login prompt 

   //Login Second time

    $this->_send($this->_username2);
    $this->_send($this->_password2);
}

Send function looks like this:

private function _send($command) 
{
    fputs($this->_connection, $command . "\r\n");
} 

So if we want to control remote power switch, there is a menu for this. In this menu user can navigate like this:

——- Control Console ——————————————————-

 1- Device Manager
 2- Network
 3- System
 4- Logout

 <ESC>- Main Menu, <ENTER>- Refresh

When we press 1, we will go to another meniu:

——- Device Manager ——————————————————–

 1- Bank Monitor
 2- Outlet Management
 3- Power Supply Status

 <ESC>- Back, <ENTER>- Refresh

and so on… So we can access the outlet which we want by just typing these numbers.

Function to reload the outlet (outlet number 22):

public function ReloadOutlet22() 
{

$this->_send('1'); // Access Device Manager
$this->_send('2'); // Access Outlet Management
$this->_send('1'); // Outlet Control/Configuration
$this->_send();    // '<Enter> to continue'
$this->_send('22'); // Access Outlet number 22
$this->_send('6');  // Delayed Reboot (reboot with 5 sec delay)
$this->_send('YES'); // 'Yes' to continue
$this->_send();      // <Enter> to continue'

//Everything is working till there. I can successfully reload the outlet which I want. After the reload I want to go to the main menu and logout from this console.

$this->_send('\e');  // <Esc> - back
$this->_send('\e');  // <Esc> - back
$this->_send('\e');  // <Esc> - back
$this->_send('\e');  // <Esc> - back
$this->_send('\e');  // <Esc> - back
$this->_send('4');   // Logout
}

So there is a problem. Next time , when I want to reload another outlet, for example outlet with a number 23, I can’t successfully login to the APC PDU. I can see at the login prompt that there was a try to use ‘\e’ as a Username and as a password.

So maybe guys you have an idea, why after successful reload my code doesn’t work as it should? Why I can’t go back to the main menu and logout?

Thank you for your time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T02:52:46+00:00Added an answer on June 12, 2026 at 2:52 am

    APC provides both the Control Console (text-based menu driven), and also their Command Line Interface (“CLI”) which accepts a variety of command lines specific to controlling the PDU’s outlets.

    To use the Command Line Interface instead of the Control Console, append ” -c” to your password when logging in with telnet–i.e., if your telnet password is “abcdefg”, then login with password “abcdefg -c” to enter the CLI. The CLI command prompt is “APC>”.

    The CLI command to power cycle (reboot) an outlet is simply :

    APC> reboot x
    (x = the outlet number to power cycle)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to select an H1 element which is the second-child in its group
I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.