mridula
1
Hi
i used the following code to copy a directory from a source location to dest.
argv[1] contains the source loc i/p by the user.
strcpy(source,argv[1]);
strcpy(dest,"/home/MainServer/Job_dir/");
system("cp -r $source $dest");
it complies properly but during execution of the program it gives the following warning:
try cp --help
can anyone help me out with this?
thanx!
try with these modifications
char str[100];
strcpy(source,argv[1]);
strcpy(dest,"/home/MainServer/Job_dir/");
/* system("cp -r $source $dest"); */
sprintf(str,"cp -r %s %s", source, dest);
system(str);
devesh
3
U can not use $ with C variables as in shell. U have to use sprintf() to format the command in a string and then pass that string to system().