Y
yezi
Hi: I am coding to output the result to the tmp file in order to send
to the client. The following is the code I write to output the system
call to a tmp file "tmp.txt". However, when running it, it generate the
message like " Segmentation fault (core dumped)"
Really confused by that . Any comments is welcomed.
tmpfile = fopen("tmp.txt","a+");
if(tmpfile == NULL) {
perror("Error: can't open file.\n");
exit(1);;
}
startTm = time(NULL);
ptr = localtime(&startTm);
//Print the time of request and Time on the server side
fprintf(tmpfile,"The client IP is %s, The systime
is,",inet_ntoa(their_addr.sin_addr));
fprintf(tmpfile,asctime(ptr)); //show time problem ???
fprintf(tmpfile,"\n The command is %s, The status is
%s\n",buf,status);
sep[20]="ls";
//process the buffer content
strcat(sep,"> tmp.txt");
system(sep);
to the client. The following is the code I write to output the system
call to a tmp file "tmp.txt". However, when running it, it generate the
message like " Segmentation fault (core dumped)"
Really confused by that . Any comments is welcomed.
tmpfile = fopen("tmp.txt","a+");
if(tmpfile == NULL) {
perror("Error: can't open file.\n");
exit(1);;
}
startTm = time(NULL);
ptr = localtime(&startTm);
//Print the time of request and Time on the server side
fprintf(tmpfile,"The client IP is %s, The systime
is,",inet_ntoa(their_addr.sin_addr));
fprintf(tmpfile,asctime(ptr)); //show time problem ???
fprintf(tmpfile,"\n The command is %s, The status is
%s\n",buf,status);
sep[20]="ls";
//process the buffer content
strcat(sep,"> tmp.txt");
system(sep);