Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # SonicWall credentials
- host="XXXX"
- username="admin"
- password="XXXX"
- # SonicWall CLI configuration
- user_pattern="User:"
- password_pattern="Password:"
- prompt="NSA 3500>"
- exit_command="exit"
- newline="\n"
- # the command to run
- command="$1"
- # use expect to establish a SonicWall CLI
- # session over SSH, and then execute the
- # command.
- /usr/bin/expect -c "
- set timeout 1
- spawn ssh $host
- # log into SonicWall CLI interface
- expect \"${user_pattern}\"
- send \"${username}${newline}\"
- expect \"${password_pattern}\"
- send \"${password}${newline}\"
- # execute the command
- expect \"${prompt}\"
- send \"${command}${newline}\"
- # wait for the command to complete, and then
- # exit the CLI interface and terminate the
- # SSH session
- expect \"${prompt}\"
- send \"${exit_command}${newline}\"
- # the ssh session must be interactive, or else
- # the SonicWall will preempt the session.
- interact
- "
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement