From 78c22a7d635de4db9feaca36d85d89817494a425 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Mon, 23 Sep 2024 11:51:25 +0200 Subject: [PATCH] pySim-shell: New '-e' command line argument Using '-e' it is possible to specify *multiple* pySim-shell commands which shall be executed at startup. This extends the current ability to execute just a single command. Example: ./pySim-shell.py -p0 -e 'select ADF.USIM/EF.IMSI' -e 'read_binary_decoded' Change-Id: I74004f46105553f077c039ca0f86f75afccc7342 --- pySim-shell.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pySim-shell.py b/pySim-shell.py index 8c260aa0..37d58ae6 100755 --- a/pySim-shell.py +++ b/pySim-shell.py @@ -1056,6 +1056,8 @@ adm_group.add_argument('-a', '--pin-adm', metavar='PIN_ADM1', dest='pin_adm', de adm_group.add_argument('-A', '--pin-adm-hex', metavar='PIN_ADM1_HEX', dest='pin_adm_hex', default=None, help='ADM PIN used for provisioning, as hex string (16 characters long)') +option_parser.add_argument('-e', '--execute-command', action='append', default=[], + help='A pySim-shell command that will be executed at startup') option_parser.add_argument("command", nargs='?', help="A pySim-shell command that would optionally be executed at startup") option_parser.add_argument('command_args', nargs=argparse.REMAINDER, @@ -1122,6 +1124,13 @@ if __name__ == '__main__': print(e) print("---------------------8<---------------------") + # Run optional commands + for c in opts.execute_command: + if not startup_errors: + app.onecmd_plus_hooks(c) + else: + print("Errors during startup, refusing to execute command (%s)" % c) + # Run optional command if opts.command: if not startup_errors: