Exec multiple comands

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
papa_smurf
Forum Newbie
Posts: 14
Joined: Tue Jun 01, 2010 12:22 pm

Exec multiple comands

Post by papa_smurf »

Hello everyone,

I'm starting to go crazy looking for an answer. Is it possible to execute multiple commands from php using the exec() function?

Here is an example, I have an executable file, driv_calc.exe. When I execute that file, it prompts me with a series of options to choose from. So i'll enter 4 for option 4. Then the program will prompt me with another list and so on and so forth.

Can I perform this same task in php? If so, how? If not, why not?

Thanks
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Exec multiple comands

Post by AbraCadaver »

Only if the executable can run without user interaction with some command line args, such as: driv_calc.exe 4 2 1 4

You may be able to get this functionality using proc_open() or maybe popen().
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
papa_smurf
Forum Newbie
Posts: 14
Joined: Tue Jun 01, 2010 12:22 pm

Re: Exec multiple comands

Post by papa_smurf »

Unfortunately it does require user interaction in its current form. So basically files that are run using the exec function can only run properly if they can operate without user interaction during the process?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: Exec multiple comands

Post by AbraCadaver »

papa_smurf wrote:Unfortunately it does require user interaction in its current form. So basically files that are run using the exec function can only run properly if they can operate without user interaction during the process?
Yes, so check out proc_open() though it is quite a chore especially if you're not familiar with the process. I would search for a proc_open() tutorial and/or look at the comments on the manual page.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply