Other answers provide a way to run a series of ktutil commands and then exit.
It's more difficult to do a series of commands and then get an interactive session, with full line editing capabilities.
You can achieve this with a script for the expect
program, which should be available to install from your distro.
#!/usr/bin/env expect -f
spawn ktutil
send "read_kt [lrange $argv 0 1]\nl\n"
set CTRLZ \032
interact {
-reset $CTRLZ {exec kill -STOP [pid]}
\003 exit
}
Save as myktutil
somewhere in your PATH
and make it executable with chmod +x
Then you can do, for example:
$ myktutil foo.keytab
This will read in the keytab file foo.keytab
, list the keys and then drop you into the interactive command at that point.
Extending the script to do non-trivial things will require familiarization with expect
and the Tcl language.