Hi guys I'm trying to write to a file descriptor with execv() except instead of writing/executing where I want it, it goes straight to terminal. here's what I'm trying :
Code:
FILE* clnt_write;
clnt_write = fdopen(dup(clnt_sock),"w");
send_data(clnt_write, ct , newFile, ext); // sending file !!!
void send_data(FILE *fp, char* ct, char* file_name, char ext[])
if( strcmp(ext, "cgi") == 0){
dup2(fp, 1);
dup2(fp, 2);
close(fp);
char dot_slash[] = "./";
char *dsPtr = dot_slash;
strcat(dsPtr, file_name);
puts(dsPtr);
char *arg[2];
arg[0] = data;
arg[1] = NULL;
execv(dsPtr, arg);
}
I get the following warnings:
lab2.c: In function 'send_data':
lab2.c:246: warning: passing argument 1 of 'dup2' makes integer from pointer without a cast
lab2.c:247: warning: passing argument 1 of 'dup2' makes integer from pointer without a cast
thanks.