1. In the linux environment, call execl:
if((pid=fork())<0){
printf("fork error\n");
}else if(pid==0){ /*child*/
if(execl("/sbin/ifconfig","ifconfig","eth0","hw","ether",eth0_num,NULL)<0){
exit(1);
}else{
exit(0);
}
}
2. Where the eth0_num variable is returned by another function call and is a pointer:
:int read_data(int addr,char* data,int len)
:read_data(4, eth0_num,6);/*46eth0_num*/
3. But run-time returns are wrong:
ifconfig: invalid hw-addr
4. The value I printed for eth0_num is: 0x7e8b8bf4
*eth0_num,*(eth0_num+1),*(eth0_num+2): 00 90 8f
The value is right, but it never works. I have tried another way
to copy char * eth0_num= "1eed19271ab3" directly; and then call execl, without using the parameters of calling read_data from the function, you can ifconfig successfully
5. Give me some advice on how to pass variable parameters, because I need to read the value back from somewhere else