Welcome Guest ( Log In | Register )



 
Reply to this topicStart new topic
> Running C Applications By Php, (C - daemon)
CrazyPensil
post Jun 28 2006, 12:18 PM
Post #1


Member [ Level 1 ]
Group Icon

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)
Go to the top of the page
 
+Quote Post
Jeigh
post Jun 28 2006, 02:10 PM
Post #2


Whitest Black Mage
Group Icon

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.
Go to the top of the page
 
+Quote Post
Hercco
post Jun 30 2006, 01:56 PM
Post #3


Super Member
Group Icon

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 wink.gif, ...
Go to the top of the page
 
+Quote Post
CrazyPensil
post Jun 30 2006, 09:09 PM
Post #4


Member [ Level 1 ]
Group Icon

Group: Members
Posts: 42
Joined: 17-March 06
From: Russia, St.Petersburg
Member No.: 12,058



QUOTE(Hercco @ Jun 30 2006, 05:56 PM) *

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? wink.gif
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Running Linux on slow computers(12)
  2. Web Design For Free(12)
  3. How Many Background Processes Do You Have Running(24)
  4. How To Install Applications In Fedora(12)
  5. Running Linux On Windows (Knoppix)?(9)
  6. Status Bar Effect(5)
  7. Running Vba Script In Excel(7)
  8. List Of Free Applications(8)
  9. Cron Jobs Not Running(10)
  10. Ipb Problem On Intranet(5)
  11. Cron Jobs Not Running Then Running Off And On..(8)
  12. Running Flash 8 In A Usb Flash Drive(3)
  13. Ethernet Problem On Xubuntu(3)
  14. What If A Pc Running Xp Boots Very Slowly?(12)
  15. Prevent Specific Applications From Connecting To The Internet(2)
  1. Fewer Running Services - Better Performance(5)
  2. Port Forwarding For Webservers(0)
  3. Need Help Running Aros On The Jpc X86 Emulator....(0)
  4. Beautiful Technology At Work - Inside A Hard Drive, While It's Running(4)
  5. Remote Avatar In Phpbb3(0)
  6. C++ Running As Web-app(2)
  7. Change Default Applications(3)
  8. Anybody Use Gimp? It's Free!(16)
  9. What Applications Can I Use For Cd-audio Ripping (digital Extraction) And Encoding?(0)
  10. Need Help With Performance(4)
  11. Designing A Summer Running Program(1)
  12. Get The Current Running Machine Ip-c/c++ Coding(2)
  13. Free Web Hosting: (running With Scissors)(1)


 



- Lo-Fi Version Time is now: 5th December 2008 - 12:36 PM