Run multiple local script commands in CLI

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Run multiple local script commands in CLI

L3 Networker

Hi,

In my struggle to switch my captive portal rules on and off I want to run a script to achieve this.  I use a .bat file containing the following line:

c:\test\plink.exe -ssh 192.168.100.2 -l admin -pw mypassword -m c:\test\enable.txt

The file enable.txt contains the following lines:

configure

set rulebase captive-portal rules "My Captive Portal Rule" action web-form

commit

When I enter the above three commands in putty one after the other they are executed successfully.  However when run from a batch file it just hangs and never returns. 

I suspect that the CLI need a certain delay after being set in CONFIGURE mode until it is ready to receive the 'set rulebase....' command and likewise it needs it finish the rule changing before receiving the 'commit' command.

How can I put a delay between the three commands / lines above so my script executes as successfully using plink as it does when entering the same commands manually in putty?

Thanks a lot for help on this

regards Tor

2 REPLIES 2

L7 Applicator

You could look into other specialized CLI handling scripting tools available such as Expect (based on TCL) that handles the prompt/wait inherently.   Expect - Expect - Home Page

There is a special community called the DevCenter devoted to custom scripting/automation. Such questions regarding external scripting/automation are better addressed via the DevCenter community https://live.paloaltonetworks.com/community/devcenter

L5 Sessionator

This seems like a limitations of plink.

(someone's blog)

http://blogs.lockstepgroup.com/2012/12/scripting-with-palo-alto-networks.html

I also could not make it work and I've never seen anyone succeeded. It doesn't work even with 1 command, like "show system info". plink -v (verbose) option shows that it stops at "Started a shell/command".

As goku suggested, I would also recommend you to use other scripts. I prefer perl.

- Yasu

  • 4943 Views
  • 2 replies
  • 0 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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!