2

I have a server running an application (puppet) and administration of the server is done almost exclusively with that programs specific commands.

It would be neat to configure the server like a dedicated appliance similar to how a Cisco IOS works with the puppet command.

The puppet command has many arguments many of which also requires elevation so im frequently typing "sudo puppet command subcommand subcommand argument".

I want to be able to type "sudo puppet" and then enter the "puppet" context where I only have to type the top level commands without having to type "sudo puppet command".

Then after I enter the command and I'm in the commands context and I only have to enter the sub command and argument to the subcommand.

Is it clear what I'm trying to accomplish? Is this possible?

  • You could use something like read variable && puppet $variable. – DisplayName Dec 5 '15 at 15:43
4

This is actually fairly easy to accomplish, you can use a script like this:

#!/bin/bash
while [ 1 ]; do
    echo -n "puppet> "
    read input
    puppet $input
done

Save with a name like foo.sh, then just run sudo bash foo.sh (or sudo ./foo.sh if you set the executable flag).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.