LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-18-2004, 10:16 AM   #1
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Rep: Reputation: 69
php problem


hi there
i am new to php and i am facing some problems here

1.i want to shoow the output of my C program in the browser
for this i have tried
exec,system, passthru, functions

all of them are workuing for programs where i do not need to pass any arguments

in case of programs where i need to pass arguments it is not working,i have tried escapeshellargs(), and also ' ' (what they call it,i do not remember)

when iam using other commands eg. 'ls -la' they are working fine but my program is not working although it works like this in the shell

#force gaurav

where gaurav is the argument to be pased.

2. also the output of my program consists of displaying a list of users. in the C program it is displayed with a break by using '/n' but when i use the C program through php the o/p is displayed in a continous line.


please help


regards
gaurav
 
Old 07-29-2004, 05:35 PM   #2
Chris Parker
LQ Newbie
 
Registered: Jul 2004
Location: Houston, Texas
Distribution: Debian, Gentoo, Redhat
Posts: 17

Rep: Reputation: 0
Code:
<?php
$arg = "-l";

exec ("ls  $arg", $a);
for ($i = 0; $i < count ($a); $i++) {
        echo $a[$i]."\n";
}
?>
This works for me. I am assuming that you are passing an argument to your program and your program writes to the stdout.

Post the c program code if you are still having problems.
 
Old 07-30-2004, 04:50 AM   #3
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 111Reputation: 111
Quote:
1.i want to shoow the output of my C program in the browser
for this i have tried
exec,system, passthru, functions
The easiest is to use popen().
See: http://www.php.net/manual/en/function.popen.php
 
Old 07-30-2004, 06:36 AM   #4
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Original Poster
Rep: Reputation: 69
hi there
thanks for ur reply
i found out what was going wrong..
actualling my program requires root permissions but apache executes them with username 'apache'
so could not complete it
so i gave
'chmod u+s force'

this now allows apache to execute the program

hey one more thing
how do refresh screen in php
there is one program

ncurses_refresh(int ch)

ony this much is given in the php.net manual

any other functions are there???

pl. help
 
Old 07-30-2004, 06:46 AM   #5
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
I would think you need "refresh" your page because it was cached by your web browser client so take a look in documentation for header() :

http://fr3.php.net/header

And scroll down until you find the 5 examples of use the header() function to disable cache
 
Old 07-31-2004, 09:22 AM   #6
masand
LQ Guru
 
Registered: May 2003
Location: INDIA
Distribution: Ubuntu, Solaris,CentOS
Posts: 5,522

Original Poster
Rep: Reputation: 69
i just want to reload the page again
 
Old 07-31-2004, 09:32 AM   #7
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 244Reputation: 244Reputation: 244
You could use the header() function in php or document.location.replace() in javascript to refresh your page, but both function can refresh your page in an infinite loop if you take a bad approach to do things.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
php apache or php cgi - php learner rblampain Linux - Security 3 12-17-2004 11:10 PM
New to PHP and Postgressql. Is this a PHP problem or a sql problem. Please help sendas4 Linux - General 2 11-05-2004 01:54 PM
Problem getting PHP to recognize MySQL, Using PHP 4.0 and MySQL 4.0.20 d2army Programming 4 06-27-2004 08:54 PM
RH9: PHP session problem (or Apache problem) fengcn Red Hat 0 12-01-2003 06:32 PM
Apache php index.php problem neurotic Linux - Software 3 11-18-2003 06:02 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration