2

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.

2 Answers 2

4

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
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, when trying to do so, it seems that the php looking for more commends, it does respond only open a php ?
1

Create a file like this:

launcher.php

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

Then in your bash script:

php launcher.php

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.