Home > Article > Backend Development > Linux system command php method to execute system command
The code is as follows:
Copy the code The code is as follows:
#include
#include
#include
#include < unistd.h>
#include
int main(int argc,char * argv[])
{
uid_t uid,euid;
char cmd[1024]="chmod -R 777 ";
uid =getuid();
euid = geteuid();
//printf("param %sn",strcat(cmd,argv[1]));
//exit(0);
//printf("uid: %un. eudi=%unn",getuid(),geteuid());
if(setreuid(euid,uid))
perror("setreuid");
//printf("uid:%un. eudi=% unn",getuid(),geteuid());
system(strcat(cmd,argv[1]));
return 0;
}
Copy code The code is as follows:
$chmod_line = dirname(__FILE__) ."/phpchmod ./dest_dir/";
system($chmod_line);
The above introduces the Linux system command PHP method of executing system commands, including the content of Linux system commands. I hope it will be helpful to friends who are interested in PHP tutorials.