How to execute commands from a ubuntu executable in php?

1

I run the following line in ubuntu:

needle alvo.txt modelo.txt

When running it displays these lines:

Needleman-Wunsch global alignment of two sequences

I need to give an enter to go as default in this:

Gap opening penalty [10.0]:

and in this:

Gap extension penalty [0.5]:

and one more enter to have the final file on this line:

Output alignment [hba_human.needle]:

How would you put these commands to run in php code?

I tried running the command shell_exec ('needle alvo.txt modelo.txt') the problem is that the program is not a one-line executable I need to give the Enters to default to the other lines.

    
asked by anonymous 02.08.2017 / 23:48

1 answer

0

You can write a script in expect and call it from your PHP code. Example:

#!/usr/bin/expect

set timeout 10
set alvo [lindex $argv 0]
set modelo [lindex $argv 1]

spawn ./needle $alvo $modelo
expect "Gap opening"    {send "\r"}
expect "Gap extension"  {send "\r"}
expect "Gap alignment"  {send "\r"}

This script basically executes your command line and waits for the "Gap ..." returns to send the "Enter".

    
03.08.2017 / 19:15