Set env vars when using -c
This commit is contained in:
parent
679ab536f5
commit
91318c2c5f
3 changed files with 12 additions and 4 deletions
|
@ -110,7 +110,7 @@ it will actually use `eth0:42`. To override this, manually specify an alias (e.g
|
|||
This error message could also indicate a bug in the TFTP code; try using an external tftp
|
||||
client (busybox in this example), by specifying the `-c` flag instead of the `-f` flag:
|
||||
|
||||
`# nmrpflash -i eth0 -c "busybox tftp -p -l EX2700-V1.0.1.8.img @IP@"`
|
||||
`# nmrpflash -i eth0 -c "busybox tftp -p -l EX2700-V1.0.1.8.img \$IP"`
|
||||
|
||||
###### "Timeout while waiting for CLOSE_REQ."
|
||||
|
||||
|
|
3
main.c
3
main.c
|
@ -67,6 +67,9 @@ void usage(FILE *fp)
|
|||
#else
|
||||
"C:\\> nmrpflash.exe -i net0 -f firmware.bin\n"
|
||||
#endif
|
||||
"\n"
|
||||
"When using -c, the environment variables IP, NETMASK and MAC are\n"
|
||||
"set to the device IP address, subnet mask and MAC address.\n"
|
||||
"\n"
|
||||
"nmrpflash %s, Copyright (C) 2016 Joseph C. Lehner\n"
|
||||
"nmrpflash is free software, licensed under the GNU GPLv3.\n"
|
||||
|
|
11
nmrp.c
11
nmrp.c
|
@ -43,6 +43,10 @@
|
|||
#define PACKED __attribute__((__packed__))
|
||||
#endif
|
||||
|
||||
#ifdef NMRPFLASH_WINDOWS
|
||||
#define setenv(name, value, overwrite) SetEnvironmentVariable(name, value)
|
||||
#endif
|
||||
|
||||
enum nmrp_code {
|
||||
NMRP_C_NONE = 0,
|
||||
NMRP_C_ADVERTISE = 1,
|
||||
|
@ -631,10 +635,11 @@ int nmrp_do(struct nmrpd_args *args)
|
|||
status = 0;
|
||||
|
||||
if (args->tftpcmd) {
|
||||
printf("Executing '%s' ... ", args->tftpcmd);
|
||||
fflush(stdout);
|
||||
printf("Executing '%s' ... \n", args->tftpcmd);
|
||||
setenv("IP", inet_ntoa(ipconf.addr), 1);
|
||||
setenv("MAC", mac_to_str(rx.eh.ether_shost), 1);
|
||||
setenv("NETMASK", inet_ntoa(ipconf.mask), 1);
|
||||
status = system(args->tftpcmd);
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (!status && args->file_local) {
|
||||
|
|
Loading…
Add table
Reference in a new issue