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

Quizer

New member
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?
 

Darzil

Developer
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 ;
 

Quizer

New member
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!
 

Bale

Minion
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
	}
 

Stewbeef

New member
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
	}

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).
 

Veracity

Developer
Staff member
Think of cli_execute, in this case, as a keyword, like "for" or "if", rather than as the cli_execute() function.
 

Saklad5

Member
I always just used the cli_execute() function with semicolons delimiting multiple commands. Is that less efficient than using the brace notation, or functionally equivalent?
 

heeheehee

Developer
Staff member
It's equivalent, but I find the brace notation (with each command on its own line) easier to read and edit.
 
Top