Hello,

I am trying to connect a unix server using ssh (phpseclib) and running an external program like 'C' program. I am using exec() to run .exe. My code looks this way

echo $ssh->exec('./demo.exe');

demo.exe is a executable for program to add two numbers and the inputs are hardcoded within the 'C' program.

This piece of code works perfectly when the inputs are hardcoded in the 'C' program. But when I try to pass the arguments to exec(), the php script becomes unresponsive. After modification to accept inuts for .exe, my code looks this way,

echo $ssh->exec("./demo.exe, '10 20'");

where demo.exe is a, executable for a simple program to add two numbers and 10 and 20 are inputs to the executable. I did modify the code as some of my friends suggested like

$ssh->exec("./demo.exe '10' '20'"); 
$ssh->exec("./demo.exe ; '10 20'"); 
$ssh->exec('./demo.exe 10 20');

but none of them worked. All the above php scripts became unresponsive. Could any one throw some light on this. Any inputs on this are greately appreciated.

Thanks in advance..

Recommended Answers

All 2 Replies

Are you on a Windows system? (Guessing by the EXE extension but I may be wrong)
If so, you need to give Apache2 permision to 'Interact with the desktop'
To do this go Start->Run->(Type 'services.msc')->(Locate the Apache2 service)->Right Click->Properties->Log On
Make sure 'Local System Account' is selected then check 'Allow service to interact with desktop'
If you're on a UNIX based system ignore all that =)

Hey Thanks for your reply, I am working in unix server.. so I dont think this will work.
I used .exe to represent "a.out" in C program. Probably something to do with exec() so that it accepts inputs..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.