- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
11-03-2023 09:10 AM - edited 11-06-2023 12:45 AM
Hello, I'm using the code below to get ha state on my palo alto firewall but the output is not ok, there is a loop one the command and extra output caracters.
I'm using it with ansible in this scenario: ansible connect to a jumthost that execute this expect script on the palo alto device
#!/usr/bin/expect
set send_human {.1 .3 1 .05 2}
set network_expect_instructions_prompt "@.*>"
set network_expect_instructions_exitcode_wrong_password "2"
set network_expect_instructions_time_to_sleep "3"
set network_expect_instructions_timeout "30"
set timeout "30"
set network_target_pass "$env(NETWORK_TARGET_PASS)"
# commands communes de connectivités
spawn ssh -o StrictHostKeyChecking=no user@paloalto
expect {
-re "Password:" {
if { 0==1 } { puts "prompt ok!!"}
send -h "$network_target_pass\r"
}
timeout {
puts "no password: prompt"
set exit_code 3
if { $exit_code!=0 } { exit $exit_code }
}
}
# commandes de l'instructions
puts "EXPECT_BEGIN\r"
expect {
-re "$network_expect_instructions_prompt" {
if { 0==1 } { puts "prompt ok!!"}
send -h "show high-availability state\r"
}
timeout {
puts "prompt $network_expect_instructions_prompt not found."
set exit_code 3
if { $exit_code!=0 } { exit $exit_code }
}
}
expect {
-re "$network_expect_instructions_prompt" {
if { 0==1 } { puts "prompt ok!!"}
send -h "exit\r"
}
timeout {
puts "prompt $network_expect_instructions_prompt not found."
set exit_code 3
if { $exit_code!=0 } { exit $exit_code }
}
}
puts "EXPECT_END\r"
Here is the output
user@paloalto> show high-availability state\r
\r\u001b[K\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000user@paloalto> show \r\u001b[K\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000user@paloalto> show high-availability \r\u001b[K\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000user@paloalto> show high-availability state \r\u001b[K\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000user@paloalto> show high-availability state \r
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!