Translate to:
Please select
  • English (English)
  • French (Français)
  • German (Deutsch)
  • Indonesian (Bahasa Indonesia)
  • Italian (Italiano)
  • Portuguese (Português)
  • Russian (Русский)
  • Spanish (Español)
  • Thai (ไทย)
  • Turkish (Türkçe)
  • Vietnamese (Tiếng Việt)
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Automated scripting on Switched Rack PDU

APC UPS Data Center & Enterprise Solutions Forum

Schneider, APC support forum to share knowledge about installation and configuration for Data Center and Business Power UPSs, Accessories, Software, Services.

Search in

Improve your search experience:

  • Exact phrase → Use quotes " " (e.g., "error 404")
  • Wildcard → Use * for partial words (e.g., build*, *tion)
  • AND / OR → Combine keywords (e.g., login AND error, login OR sign‑in)
  • Keep it short → Use 2–3 relevant words , not full sentences
  • Filters → Narrow results by section (Knowledge Base, Users, Products)
Enter a search word
    Turn off suggestions

    Didn't find what you were looking for? Explore advanced search

    Enter a search word
      Turn off suggestions

      Didn't find what you were looking for? Explore advanced search

      Enter a user name or rank
        Turn off suggestions

        Didn't find what you were looking for? Explore advanced search

        Enter a search word
          Turn off suggestions

          Didn't find what you were looking for? Explore advanced search

          Enter a search word
            Turn off suggestions

            Didn't find what you were looking for? Explore advanced search

            cancel
            Turn on suggestions
            Showing results for 
            Show  only  | Search instead for 
            Did you mean: 
            Important Note
            • Home
            • Schneider Electric Community
            • APC UPS, Critical Power, Cooling and Racks
            • APC UPS Data Center & Enterprise Solutions Forum
            • Re: Automated scripting on Switched Rack PDU
            Options
            • Mark Topic as New
            • Mark Topic as Read
            • Float this Topic for Current User
            • Bookmark
            • Subscribe
            • Mute
            • Printer Friendly Page
            Invite a Co-worker
            Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
            You have entered an invalid email address. Please re-enter the email address.
            This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
            Please enter email address
            Send Invite Cancel
            Invitation Sent
            Your invitation was sent.Thanks for sharing Exchange with your co-worker.
            Send New Invite Close
            Top Experts
            User Count
            BillP
            Administrator BillP Administrator
            5060
            voidstar_apc
            Janeway voidstar_apc
            196
            Teken
            Spock Teken
            136
            Erasmus_apc
            Sisko Erasmus_apc
            112
            View All

            Free

            English

            Data Center Certified Associate Exam Development Path

            Strengthen your foundational knowledge in Data Centers for free, enroll in this path today and start your learning journey!

            4.0
            Register Browse SE University

            Invite a Colleague

            Found this content useful? Share it with a Colleague!

            Invite a Colleague Invite
            Solved Go to Solution
            Back to APC UPS Data Center & Enterprise Solutions Forum
            Start a Topic
            Solved
            Anonymous user
            Not applicable

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:26 AM

            0 Likes
            6
            7108
            • Mark as New
            • Bookmark
            • Subscribe
            • Mute
            • Permalink
            • Print
            • Email to a Friend
            • Report Inappropriate Content

            Link copied. Please paste this link to share this article on your social media post.

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:26 AM

            Automated scripting on Switched Rack PDU

            Hello all,

            I am programming a little bash script that checks whether a machine is down or not, and if yes, it reboots the machine.

            For doing so, it needs to connect to the PDU and launch the "reboot" command on the outlet to which the machine is connected.

            The problem is that I want this to be automated but the ssh (and telnet) connection keeps asking me for the password... Isn't it possible to install a key certificate so that password is not required during my script execution?

            I've read the manual but I can't figure out how to run automated scripts on the PDU.
            Any ideas on this?

            Thanks in advanced!!
            Pedro

            Labels
            • Labels:
            • Racks, Rack Accessories, & Cooling
            • Tags:
            • pdu
            • script
            • scripting
            • ssh
            • telnet
            Reply

            Link copied. Please paste this link to share this article on your social media post.

            • All forum topics
            • Previous Topic
            • Next Topic

            Accepted Solutions
            Anonymous user
            Not applicable

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:25 AM

            1 Like
            1
            7104
            • Mark as New
            • Bookmark
            • Subscribe
            • Mute
            • Permalink
            • Print
            • Email to a Friend
            • Report Inappropriate Content

            Link copied. Please paste this link to share this article on your social media post.

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:25 AM

            Hi,
            After some trial and error, and a few coffees too, I've managed to program a simple script that does what I mentioned.

            Unfortunately, a UNIX tool called "expect" is needed, which is not installed by default in all UNIX-based distribution. You can install it via apt-get or yum (depending on your distribution)

            The script basically waits until a string similar to the pattern given to "expect" is written on the console prompt, and then it sends the passwords (or commands) as if they were written by the user. The script works both for telnet and ssh2 connections (can't guarantee ssh1 since my workstation hasn't got it installed).

            The code is the following:

            // USE ---> /ssh_command.sh user password ip

            // set Variables
            set user [lrange $argv 0 0]
            set password [lrange $argv 1 1]
            set ipaddr [lrange $argv 2 2]
            set timeout -1

            // now connect to remote PDU
            // using TELNET---> spawn telnet $ipaddr
            spawn ssh $user@$ipaddr
            match_max 100000

            // Using TELNET
            //expect "User Name :"
            //send "$user"

            // Look for passwod prompt
            expect "*?assword*"
            // Send password aka $password
            send "$password"
            expect "APC>"

            send "off 1"
            expect "APC>"

            sleep 3

            send "on 1"
            expect "APC>"

            send "exit"

            expect eof
            close $spawn_id

            I hope this helps anyone with the same problem.

            PS:
            I tried to change the fingerprint of the PDU, but that didn't work because the fingerprint identifies the PDU so when other clients connect to it, they can trust this host (the PDU). However, the PDU wasn't able to recognize clients.

            Tried also to upload the fingerprint of my workstation to a directory in the PDU (specifically "~/.ssh" as it says this tutorial), but the ftp server that runs on the PDU isn't very flexible, and doesn't allow you to create folders or so.

            Message was edited by: pedriyoo

            Message was edited by: pedriyoo

            See Answer In Context

            Reply

            Link copied. Please paste this link to share this article on your social media post.

            Replies 6
            BillP
            Administrator BillP Administrator
            Administrator

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2025-05-30 12:30 AM

            0 Likes
            0
            7104
            • Mark as New
            • Bookmark
            • Subscribe
            • Mute
            • Permalink
            • Print
            • Email to a Friend
            • Report Inappropriate Content

            Link copied. Please paste this link to share this article on your social media post.

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2025-05-30 12:30 AM

            what model PDU is it? There is a scriping CLI on our two generations of PDUs outlined 

            Reply

            Link copied. Please paste this link to share this article on your social media post.

            Anonymous user
            Not applicable

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:25 AM

            0 Likes
            0
            7104
            • Mark as New
            • Bookmark
            • Subscribe
            • Mute
            • Permalink
            • Print
            • Email to a Friend
            • Report Inappropriate Content

            Link copied. Please paste this link to share this article on your social media post.

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:25 AM

            It is a AP7920 device.

            I can connect to the command line, but I'd like to connect to it using a certificate, so I can make an ssh connection in a script automatically, without giving out the password.

            Reply

            Link copied. Please paste this link to share this article on your social media post.

            BillP
            Administrator BillP Administrator
            Administrator

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:25 AM

            0 Likes
            0
            7104
            • Mark as New
            • Bookmark
            • Subscribe
            • Mute
            • Permalink
            • Print
            • Email to a Friend
            • Report Inappropriate Content

            Link copied. Please paste this link to share this article on your social media post.

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:25 AM

            what SSH client are you using? i would think you could put the key in its keystore but i guess i have never tried. i am not sure if there is a way to get around typing the password completely 😕

            Reply

            Link copied. Please paste this link to share this article on your social media post.

            Anonymous user
            Not applicable

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:25 AM

            1 Like
            1
            7105
            • Mark as New
            • Bookmark
            • Subscribe
            • Mute
            • Permalink
            • Print
            • Email to a Friend
            • Report Inappropriate Content

            Link copied. Please paste this link to share this article on your social media post.

            Posted: ‎2021-06-28 06:22 AM . Last Modified: ‎2024-03-18 02:25 AM

            Hi,
            After some trial and error, and a few coffees too, I've managed to program a simple script that does what I mentioned.

            Unfortunately, a UNIX tool called "expect" is needed, which is not installed by default in all UNIX-based distribution. You can install it via apt-get or yum (depending on your distribution)

            The script basically waits until a string similar to the pattern given to "expect" is written on the console prompt, and then it sends the passwords (or commands) as if they were written by the user. The script works both for telnet and ssh2 connections (can't guarantee ssh1 since my workstation hasn't got it installed).

            The code is the following:

            // USE ---> /ssh_command.sh user password ip

            // set Variables
            set user [lrange $argv 0 0]
            set password [lrange $argv 1 1]
            set ipaddr [lrange $argv 2 2]
            set timeout -1

            // now connect to remote PDU
            // using TELNET---> spawn telnet $ipaddr
            spawn ssh $user@$ipaddr
            match_max 100000

            // Using TELNET
            //expect "User Name :"
            //send "$user"

            // Look for passwod prompt
            expect "*?assword*"
            // Send password aka $password
            send "$password"
            expect "APC>"

            send "off 1"
            expect "APC>"

            sleep 3

            send "on 1"
            expect "APC>"

            send "exit"

            expect eof
            close $spawn_id

            I hope this helps anyone with the same problem.

            PS:
            I tried to change the fingerprint of the PDU, but that didn't work because the fingerprint identifies the PDU so when other clients connect to it, they can trust this host (the PDU). However, the PDU wasn't able to recognize clients.

            Tried also to upload the fingerprint of my workstation to a directory in the PDU (specifically "~/.ssh" as it says this tutorial), but the ftp server that runs on the PDU isn't very flexible, and doesn't allow you to create folders or so.

            Message was edited by: pedriyoo

            Message was edited by: pedriyoo

            Reply

            Link copied. Please paste this link to share this article on your social media post.

            smallfish01
            Crewman smallfish01
            Crewman

            Posted: ‎2022-04-28 11:17 PM

            In response to Anonymous user
            0 Likes
            0
            6641
            • Mark as New
            • Bookmark
            • Subscribe
            • Mute
            • Permalink
            • Print
            • Email to a Friend
            • Report Inappropriate Content

            Link copied. Please paste this link to share this article on your social media post.

            Posted: ‎2022-04-28 11:17 PM

            Hello,

             

            Thanks for your provided the script, I have tried and found when I running the script ssh to PDU, but hung when I running the script.

             

            # ./apc.sh apc apc 192.168.1.7

            spawn ssh apc@192.168.1.7
            apc@192.168.1.7's password: apc

             

            Do you know the reason?

             

            Thank you.

            • Tags:
            • english
            Reply

            Link copied. Please paste this link to share this article on your social media post.

            MyElectrons
            Crewman MyElectrons
            Crewman

            Posted: ‎2022-08-16 06:55 PM

            0 Likes
            0
            6159
            • Mark as New
            • Bookmark
            • Subscribe
            • Mute
            • Permalink
            • Print
            • Email to a Friend
            • Report Inappropriate Content

            Link copied. Please paste this link to share this article on your social media post.

            Posted: ‎2022-08-16 06:55 PM

            Hello to all happy APC Switched and Metered PDU owners and admins! 🙂

             

            Last weekend I needed to automate outlet switching in my home lab. Here's what I've got for ap7901 & ap7902 PDUs:

            https://github.com/MyElectrons/PDU-Commander

             

            A sample command, executed from bash command line or a script:

            ./pdu-commander.py -a 192.168.7.242 -u device -p goodpassword on:1-2,8 delay:3 off:2 get:power

             

            Script's output:

            Address: 192.168.7.242
            Unit ID: ap7902
            Outlets: 16
            ('on', '1-2,8')
            1: Outlet 1       : Outlet Turned On
            2: Outlet 2       : Outlet Turned On
            8: Outlet 8       : Outlet Turned On
            ('delay', '3')
            ('off', '2')
            2: Outlet 2       : Outlet Turned Off
            ('get', 'power')
            168 VA
            168 Watts

             

            There's logging, error handling, and a big potential for growth in that little project.

            New features, improvement suggestions, and pull requests are very welcome!

             

            Cheers,

             - Serge

            • Tags:
            • ap7900
            • ap7901
            • ap7902
            • cli
            • english
            • pdu
            • python
            • script
            Reply

            Link copied. Please paste this link to share this article on your social media post.

            Preview Exit Preview

            li.media.uploader-dialog.title

            • li.media.uploader-dialog.tabs.upload li.media.uploader-dialog.tabs.upload
            • li.media.uploader-dialog.tabs.web li.media.uploader-dialog.tabs.web
            • li.media.uploader-dialog.tabs.saved li.media.uploader-dialog.tabs.saved
            li.media.album-selector.label
            • li.media.album-selector.title
            • li.media.album-selector.new.title
            • li.media.album-selector.label
              • li.media.album-selector.title
              • li.media.album-selector.new.title
              li.media.image-upload.drag
              li.media.image-upload.drop
              li.media.image-upload.mobile.instruction
              li.media.image-upload.no-flash
            li.media.uploader-dialog.title

            never-displayed

            You must be signed in to add attachments

            never-displayed

             

            You’ve reached the end of your document

            WHAT’S NEXT?

            Ask our Experts

            Didn't find what you are looking for? Ask our experts!

            My Dashboard

            Check out the new Feeds and activities that are relevant to you.

            To The Top!

            Forums

            • APC UPS Data Center Backup Solutions
            • EcoStruxure IT
            • EcoStruxure Geo SCADA Expert
            • Metering & Power Quality
            • Schneider Electric Wiser

            Knowledge Center

            Events & webinars

            Ideas

            Blogs

            Get Started

            • Ask the Community
            • Community Guidelines
            • Community User Guide
            • How-To & Best Practice
            • Experts Leaderboard
            • Contact Support
            Brand-Logo
            Welcome to Schneider Electric Community!
            Forum-Icon

            You have two options to continue your visit.

            LOGIN / Register

            Why logging in?
            • You enable the complete set of features available, such as posting, sharing, subscribing, private messaging and more.
            • You unlock the access to the whole content that Schneider Electric Community has to offer, including the gated items and the special events.
            And it’s free of charge!!!

            OR

            Continue as a guest

            Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

            Welcome!

            Welcome to your new personalized space.

            of 1

            Explore
            Translating the page…
            The page is currently translating. Please wait.
            Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.