I recently upgraded to an RPi5. Glad for that. No issue with the SBC. Hoping I can get help with Expect programming.
Cannot get wait or sleep to delay script processing. Will post sample. First objectives and equipment.
Objective is to start and stop servers with outboard hard drives using expect on a RPi5.
Equipment RPi5 running Ubuntu (will test scripts with RaspberryPi OS)
HP DL380 Gen8 connection through iLO4 net port
Outboard drive cage.
Server Technology Sentry CW series CDU through net port
The scripts work. However, would like to pad the execution time between starting and stopping the server and outboard drives. Noted: the equipment has outdated kex. I can login in manually with telnet and ssh to start and stop. Expect will hang using the standard clients. PUTTY allows now obsoleted kex. And the CLI version PLINK uses the PUTTY saved kex exchange. The Expect script will zing through the connections faster than the hardware has fully changed on/off state. Would like the script to be delayed some seconds to allow a clean execution of hardware control.
#!/usr/bin/expect
set timeout 120
set send_slow {10 .001}
spawn plink -telnet 111.111.111.1
# -telnet starts plink on port 23
expect "Username: "
send "user\r"
expect "Password: "
send "XXXXXXX\r"
expect "Switched CDU: "
send "status\r"
expect "Switched CDU: "
send "on .a6\r"
# expect "*On"
# send "\r"
expect "*witched CDU: "
send "exit\r\n"
# send "\r"
# sleep 60
# wait 60
spawn plink 111.111.111.0 -l user
# plink defaults to SSH and picks up the current user to login.
expect "*assword: "
send "XXXXXXXX\r"
expect "*session."
send "\r"
expect "*hpiLO-> "
send "power on\r"
expect "*hpiLO-> "
send "exit\r\n"
exit
# sleep 5
# wait 5
close
Ultimately, I want to use RPi5 and CRON to complete scheduled shutdowns and Node Red or Python to launch the Expect scripts on the RPi5.
Cannot get wait or sleep to delay script processing. Will post sample. First objectives and equipment.
Objective is to start and stop servers with outboard hard drives using expect on a RPi5.
Equipment RPi5 running Ubuntu (will test scripts with RaspberryPi OS)
HP DL380 Gen8 connection through iLO4 net port
Outboard drive cage.
Server Technology Sentry CW series CDU through net port
The scripts work. However, would like to pad the execution time between starting and stopping the server and outboard drives. Noted: the equipment has outdated kex. I can login in manually with telnet and ssh to start and stop. Expect will hang using the standard clients. PUTTY allows now obsoleted kex. And the CLI version PLINK uses the PUTTY saved kex exchange. The Expect script will zing through the connections faster than the hardware has fully changed on/off state. Would like the script to be delayed some seconds to allow a clean execution of hardware control.
#!/usr/bin/expect
set timeout 120
set send_slow {10 .001}
spawn plink -telnet 111.111.111.1
# -telnet starts plink on port 23
expect "Username: "
send "user\r"
expect "Password: "
send "XXXXXXX\r"
expect "Switched CDU: "
send "status\r"
expect "Switched CDU: "
send "on .a6\r"
# expect "*On"
# send "\r"
expect "*witched CDU: "
send "exit\r\n"
# send "\r"
# sleep 60
# wait 60
spawn plink 111.111.111.0 -l user
# plink defaults to SSH and picks up the current user to login.
expect "*assword: "
send "XXXXXXXX\r"
expect "*session."
send "\r"
expect "*hpiLO-> "
send "power on\r"
expect "*hpiLO-> "
send "exit\r\n"
exit
# sleep 5
# wait 5
close
Ultimately, I want to use RPi5 and CRON to complete scheduled shutdowns and Node Red or Python to launch the Expect scripts on the RPi5.
Statistics: Posted by tflemer — Sat Mar 23, 2024 4:13 pm — Replies 1 — Views 51