Results 1 to 4 of 4

Thread: How do I execute several CLI commands as a single command / script?

  1. #1
    Junior Member
    Join Date
    Jan 2018
    Posts
    2

    Default How do I execute several CLI commands as a single command / script?

    I am trying to put a series of commands together which I want to call by using an .ash script or, ideally, a command word in CLI. Entered individually into the CLI interface, these commands work. I expected it would be a simple matter to write a bunch of CLI commands into an .ash file and run that as a first step for that automation, but that didn't work.

    How do I consolidate several CLI commands like that?

  2. #2
    Developer
    Join Date
    Apr 2010
    Posts
    4,192

    Default

    You can put it in a txt file, and it'll work.

    In an ash file you'd need to put cli_execute( "command" ); as it's expecting ash commands.

    There is also the alias command to put them all in one command, you'd want alias word command.

    You can have multiple commands in one cli line by separating them with ;

  3. #3
    Junior Member
    Join Date
    Jan 2018
    Posts
    2

    Default

    Thanks, the .txt file solution is just the ticket! I also figured out how to set up an alias that calls that .txt file (with the 'call' command), so I can have it all nicely formatted in there for my viewing pleasure (since it'll ignore spaces and such) and I can just use the keyword to run it whenever! Thanks for your help!

  4. #4
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    I am partial to this data structure for using multiple cli commands in the middle of an ash script.

    Code:
    	cli_execute {
    		CLIcommand1
    		CLIcommand2
    		CLIcommand3
    	}

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •