Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13

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,768

    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
    	}

  5. #5
    Junior Member
    Join Date
    Feb 2018
    Posts
    19

    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
    	}
    Originally Posted by Bale View Post
    I can't find anything on the wiki about that. How does it work? Do the braces work just like parentheses except it can span multiple lines? (I've not actually tried doing that with parentheticals in Kolmafia).

  6. #6
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,392

    Default

    The braces delimit a block which contains CLI commands rather than ASH code.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

  7. #7
    Junior Member
    Join Date
    Feb 2018
    Posts
    19

    Default

    Because he used "cli_execute" in front, correct?

  8. #8
    Senior Member Pazleysox's Avatar
    Join Date
    Feb 2009
    Posts
    363

    Default

    Because he used "cli_execute" in front, correct?
    Originally Posted by Stewbeef View Post
    Correct.

    There's MANY cases in which you will use the braces.

  9. #9
    Junior Member
    Join Date
    Feb 2018
    Posts
    19

    Default

    Correct.

    There's MANY cases in which you will use the braces.
    Originally Posted by Pazleysox View Post
    I'm not familiar with seeing them with a function like that. Can they be used with any function? Executing it multiple times with a set of parameters defined on each line?

  10. #10
    Developer Veracity's Avatar
    Join Date
    Mar 2006
    Location
    The Unseelie Court
    Posts
    11,392

    Default

    Think of cli_execute, in this case, as a keyword, like "for" or "if", rather than as the cli_execute() function.
    Ph'nglui mglw'nafh Cthulhu
    R'lyeh wgah-nagl fhtagn.

Posting Permissions

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