How to execute commands from a Ubuntu executable in php?

Asked

Viewed 220 times

1

run in Ubuntu the following line:

needle alvo.txt modelo.txt

when running it displays these lines:

Needleman-Wunsch global alignment of two sequences

I need to enter to go as default in this:

Gap opening penalty [10.0]:

and in that:

Gap extension penalty [0.5]:

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

Output alignment [hba_human.needle]:

how to put these commands to be executed in php code?

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

  • https://stackoverflow.com/a/10666844

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 runs your command line and waits for "Gap..." returns to send "Enter".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.