How To Run a .sh file using PHP

To run a .sh file in PHP, we can either use exec() or shell_exec() function. Here is how it works:

1. Using exec() function

<?php
exec('sh filename.sh');

2. Using shell_exec() function

<?php
shell_exec('sh filename.sh');

0 0 vote
Article Rating
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
zhang
zhang
2 years ago

thank you, it helped me very much

1
0
Would love your thoughts, please comment.x
()
x