ilansch
ilansch

Reputation: 4878

Call certain php script function that run bash script

I have a php script (functions.inc):

<?php  
function exec_mount_secured_bucket(){  
exec("/ilantest/testscript.sh");  
}  
?>  

I would like to run that function from inside the shell, normally to run the script using php i would do:
php function.inc
But I want to call a certain function from that function file.

How to do it ?

Thanks.

Upvotes: 2

Views: 411

Answers (2)

Kaii
Kaii

Reputation: 20550

You can use the command line switches for this purpose:

--process-end code
-E code        Run PHP code after processing all input lines

This should do the job:

php -E 'exec_mount_secured_bucket();' function.inc

Upvotes: 4

erenon
erenon

Reputation: 19118

Create a file like this:

launcher.php

<?php
    include 'functions.inc';
    exec_mount_secured_bucket();

Then in your bash script:

php launcher.php

Upvotes: 1

Related Questions