comparison loadtools/ltmain.c @ 230:a91dc7157544

fc-loadtool: automated command script mode implemented
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 03 Aug 2017 02:12:56 +0000
parents 96332d875fc9
children 353218c38996
comparison
equal deleted inserted replaced
229:96332d875fc9 230:a91dc7157544
60 exit(1); /* error msg already printed */ 60 exit(1); /* error msg already printed */
61 continue; 61 continue;
62 case '?': 62 case '?':
63 default: 63 default:
64 usage: fprintf(stderr, 64 usage: fprintf(stderr,
65 "usage: fc-loadtool [options] ttyport\n"); 65 "usage: fc-loadtool [options] ttyport [command-script]\n");
66 exit(1); 66 exit(1);
67 } 67 }
68 if (argc - optind != 1) 68 if (argc - optind < 1 || argc - optind > 2)
69 goto usage; 69 goto usage;
70 target_ttydev = argv[optind]; 70 target_ttydev = argv[optind];
71 if (!iramimage.filename) 71 if (!iramimage.filename)
72 iramimage.filename = default_loadagent_image; 72 iramimage.filename = default_loadagent_image;
73 73
81 if (tpinterf_pass_output(1) < 0) 81 if (tpinterf_pass_output(1) < 0)
82 exit(1); 82 exit(1);
83 putchar('\n'); 83 putchar('\n');
84 if (hw_init_script[0]) { 84 if (hw_init_script[0]) {
85 printf("Executing init script %s\n", hw_init_script); 85 printf("Executing init script %s\n", hw_init_script);
86 loadtool_exec_script(hw_init_script, 1); 86 c = loadtool_exec_script(hw_init_script, 1);
87 } else
88 c = 0;
89 if (argc - optind > 1) {
90 if (c)
91 exit(1);
92 printf("Executing command script %s\n", argv[optind+1]);
93 c = loadtool_exec_script(argv[optind+1], 0);
94 if (c)
95 exit(1);
96 default_exit(0);
87 } 97 }
88 } 98 }
89 for (;;) { 99 for (;;) {
90 if (isatty(0)) { 100 if (isatty(0)) {
91 fputs("loadtool> ", stdout); 101 fputs("loadtool> ", stdout);