Check the commandline and only enter interactive shell if no additional parameters were given. If parameters were given, execute them and exit. Signed-off-by: Andy Grover <agrover@xxxxxxxxxx> --- scripts/targetcli | 23 ++++++++++++++--------- 1 files changed, 14 insertions(+), 9 deletions(-) diff --git a/scripts/targetcli b/scripts/targetcli index 877b0e7..3dd459f 100755 --- a/scripts/targetcli +++ b/scripts/targetcli @@ -24,6 +24,7 @@ from os import getuid from targetcli import UIRoot from rtslib import RTSLibError from configshell import ConfigShell +import sys class TargetCLI(ConfigShell): default_prefs = {'color_path': 'magenta', @@ -55,13 +56,6 @@ def main(): is_root = False shell = TargetCLI('~/.targetcli') - shell.con.epy_write(''' - Welcome to the B{targetcli} shell:: - Copyright (c) 2011 by RisingTide Systems LLC.\n - For help on commands, type 'help'. - - ''') - shell.con.display('') if not is_root: shell.con.display('You are not root, disabling privileged commands.') shell.con.display('') @@ -72,8 +66,19 @@ def main(): root_node.refresh() except RTSLibError, error: shell.con.display(shell.con.render_text(str(error), 'red')) - else: - shell.run_interactive() + + if len(sys.argv) > 1: + shell.run_cmdline(" ".join(sys.argv[1:])) + sys.exit(0) + + shell.con.epy_write(''' + Welcome to the B{targetcli} shell:: + Copyright (c) 2011 by RisingTide Systems LLC.\n + For help on commands, type 'help'. + + ''') + shell.con.display('') + shell.run_interactive() if __name__ == "__main__": main() -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html