views:

29

answers:

2

Hey everybody,

I have a server (debian lenny), spectral analyzer and I have downloaded collection of source codes from Steve Sharples's site. With these s. coudes I am able to connect to spectral analyzer - type command and get the responce.

For example:

my-atom:~/vxi11# ./vxi11_cmd 135.123.106.59
Input command or query ('q' to exit): *IDN?

and I get: Rohde&Schwarz,FSV-7,102004/007,1.50 SP1

Am I able to connect to this server, write command and read the responce using PHP? I was thinking about sockets, but I am not sure if the best choice.

Any help would be most appreciated.

Thanks, Petr

+1  A: 

You can execute external programs using exec, shell_exec, system, or proc_open.

I would recommend proc_open, which allows you to set up pipes for stdin, stdout, and stderr.

Check out the proc_open link.

Brandon Horsley
Thanks Brandon, I quite like shell_exec this is exactly what i want. But the trouble is that I have two physical machines (first - app (server), second - analyzer) with different IPs.How can connect from my xxx.xxx.xxx.234 to xxx.xxx.xxx.187 run the shell command, grab the data and send them.Thanks
praethorian
If you need to connect to the remote machine from php, I would recommend looking into using one of these execute methods with ssh and an identity file. You can use ssh and an identity file to execute commands on a remote server without providing a password.
Brandon Horsley
A: 

Also you can do like:

$result = `SOME_COMMAND_HERE`;
HWTech