Home > Backend Development > PHP Tutorial > How to execute system commands in php_PHP tutorial

How to execute system commands in php_PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-21 15:45:39
Original
914 people have browsed it

The code is as follows:

Copy code The code is as follows:

#include
#include < stdlib.h>
#include
#include
#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;

}

Now let’s talk about gcc compilation and restoration of rights under Linux:
Execute
gcc -Wall -o phpchmod phpchmod.c
Execute
chmod u+s ./phpchmod
Use of php code:
Copy code The code is as follows:

$chmod_line = dirname(__FILE__)."/phpchmod ./dest_dir/";
system($chmod_line);

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320313.htmlTechArticleThe code is as follows: Copy the code as follows: #include stdio.h #include stdlib.h #include sys/types. h #include unistd.h #include string.h int main(int argc,char * argv[]) { uid_t uid,e...
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template