Hi
I'm new programming in C and need help with a piece of code I need.
what I'm trying to do it to get a program to auto update, it will check for new version and if found it will download the new version and remove the old one.
here is the code
the name of the binary is program-v1.0 the content of smversion.data contains the new version, lets say (program-v1.1) so the first time run it works ok.... it will download version 1.1 and remove 1.0; however, if I run 1.1 it will download v1,1 again so the problem is thatCode:system("cd /tmp ; wget http://xxx.com/smversion.data"); FILE*dp ; char *fname; char c[20]; dp = fopen ( "/tmp/smversion.data","r" ) ; fname=argv[0]; fgets(c, 20, dp); if (strcmp(c, fname) != 0 ) { system("v=`cat /tmp/smversion.data`; wget http://xxx.com/$v; chmod +x $v"); system("rm -rf /tmp/smversion.data"); remove(fname); } else { execute the rest....... }
if (strcmp(c, fname) != 0 ) is not working ok... I have tried to prinf the value of c and fname
and both are the same so have no idea whats going on
any help or any different idea how to accomplish this would be really appreciated
thx
PS: I use system() since I have to deal with bash commands



LinkBack URL
About LinkBacks



