|
|
|
|
![]() ![]() |
Jun 28 2006, 12:18 PM
Post
#1
|
|
|
Member [ Level 1 ] Group: Members Posts: 42 Joined: 17-March 06 From: Russia, St.Petersburg Member No.: 12,058 |
I've faced up with a promlem. I've written a C-daemon(NOT C++ || C#) which needs to be run by a php-script on a UNIX-server. Can anybody explain me how to do this one using php's exec() or passthru() functions(I don't know unix)
|
|
|
|
Jun 28 2006, 02:10 PM
Post
#2
|
|
|
Whitest Black Mage Group: [MODERATOR] Posts: 1,371 Joined: 20-May 05 From: NB, Canada Member No.: 5,281 myCENTs:65.99 |
Hm, I'm sure someone will be able to help you out more, but I had to throw together a php form for my boss a few months back and it needed to pass data into a program and how I did it was simply to put
CODE chdir ('../PROG LOCATION'); echo exec('prog'); the chdir obviously was just to change it from the primary directory to where the c program was location, and then I used echo exec to call the program name... can't remember exactly "why" I used echo there, I assume it mattered haha. Sorry I can't be more help, I never really paid much attention when I did this except to get it working and don't have the time to look at it right now. |
|
|
|
Jun 30 2006, 01:56 PM
Post
#3
|
|
|
Super Member Group: Members Posts: 595 Joined: 4-September 04 Member No.: 228 |
Pretty much how Jeigh said. The echo is there because exec returns the output of the program as a string and you just wanted to print it out. Plain system() call does exactly the same.
Passthru works the same way, it just directs the binary output of the program to the browser. You'll know when you have to use it. Since you mentioned that you are not familiar with unix... Remember to chmod the right permissions for your compiled program. You can do it with command "chmod a+x program". And as a side note, you can use these functions to run anything on the server. System commands, shell scripts, php scripts |
|
|
|
Jun 30 2006, 09:09 PM
Post
#4
|
|
|
Member [ Level 1 ] Group: Members Posts: 42 Joined: 17-March 06 From: Russia, St.Petersburg Member No.: 12,058 |
Since you mentioned that you are not familiar with unix... Remember to chmod the right permissions for your compiled program. You can do it with command "chmod a+x program". Thanks for your help... But.... Humm... I've a little bit exaggerated with "a little of Unix knowledge".... Coul you tell the correct chmod? |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th December 2008 - 12:36 PM |