Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




CGI Install Only Works From Command Line


I'm running Domino R5/Solaris 7/Intel. Any program will run on the command line, but from the browser i get "Document Contains no Data", any suggestions?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Extension Loading Works In Command-line, But Not Apache Browser
all I'm trying to do is load the php_mapscript.so library into php.

Here's the php file:
Code:

dl("php_mapscriot.so")
if (extension_loaded("MapScript"))
echo "works!";
else
echo "doesn't work!";
print_r(get_loaded_extensions());

Here's from the command line:
Code:

[edfialk@niceguy mapserver]$ php phpinfo.php
<HTML>
works!
<br>Array
(
[0] =yp [1] =xml [2] =wddx [3] =tokenizer [4]
=sysvshm [5] =sysvsem [6] =>standard [7] =sockets [8]
=shmop [9] =session [10] =pspell [11] =posix [12]
=>pcre [13] =pcntl [14] =overload [15] =mime_magic
[16] =iconv [17] =gmp [18] =gettext [19] =ftp [20]
=exif [21] =dio [22] =dbx [23] =dba [24] =curl
[25] =ctype [26] =calendar [27] =bz2 [28] =bcmath
[29] =zlib [30] =openssl [31] =MapScript [32] =gd
[33] =ldap
)
<br>
Config file:/etc/php.ini

Here's from the browser:
(http://niceguy.wustl.edu/mapserver/phpinfo.php):
Code:

Warning: dl(): Unable to load dynamic library
'/usr/lib64/php4/php_mapscript.so' - /usr/lib64/php4/php_mapscript.so:
cannot open shared object file: Permission denied in
/var/www/html/mapserver/phpinfo.php on line 22
doesn't work!
Array ( [0] =yp [1] =xml [2] =wddx [3] =tokenizer [4] =>
sysvshm [5] =sysvsem [6] =standard [7] =sockets [8] =shmop [9]
=session [10] =pspell [11] =posix [12] =pcre [13] =overload
[14] =mime_magic [15] =iconv [16] =gmp [17] =gettext [18] =>
ftp [19] =exif [20] =dio [21] =dbx [22] =dba [23] =curl [24]
=ctype [25] =calendar [26] =bz2 [27] =bcmath [28] =zlib [29]
=openssl [30] =apache2handler [31] =gd [32] =ldap )

CLI ( Command-line ) PHP Displaying Source Code In-line When Programis Executed
I'm using PHP 4.4.2, and use PHP on both the command-line and the web.

I am running PHP on SuSE 10 Linux , in a VMware 5.5 workstation, using
Apache 2.0.55 , on my Dell laptop. Everything has been running flawlessly
without problems. Very amazing to use VMware, it has worked beautifully.

uname -a

Linux xxxxxxx 2.6.13-15.8-default #1 Tue Feb 7 11:07:24 UTC 2006 i686 i686 i386
GNU/Linux

php -v
PHP 4.4.2 (cli) (built: Feb 7 2006 20:13:29)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies

php -m

[PHP Modules]
bcmath
bz2
calendar
ctype
curl
dbx
dio
domxml
exif
ftp
gd
gettext
gmp
iconv
mcrypt
mssql
mysql
ncurses
openssl
overload
pcre
posix
session
shmop
sockets
standard
sysvsem
sysvshm
tokenizer
wddx
xml
yp
zlib

When I run the following program from the command line it prints out the
source code as well as the output from the program. I run other PHP programs
on the command-line and this doesn't happen. It's really peculiar. The
error output is below.

I copied this off of php.net, and have modified it only slightly to allow
command-line input. I was trying to find a CSV solution, which I ended up
finding elsewhere, but am curious why this program would error out the
way it does--have I misconfigured something? My php.ini is basically
unchanged, if at all. I think I might have set the path to mysql but that's
about it. When I run this program from the web it works without error.

<?php

if ( $argv[0] )
{
$file = $argv[0] ;
}
else{
$file = $_GET['file'] ;
print "<font face=arial>
" ;
}

$row = 1;

$handle = fopen("$file", "r");

while ( ( $data = fgetcsv($handle, 1000, ",") ) !== FALSE )
{

$num = count($data);

print "$num fields in line $row:<br>
";

$row++;

for ($c = 0; $c < $num; $c++)
{
print "$data[$c]<br>
" ;

Apache Conf To Make The PHP's System Command Works On Linux.
I've got a big problem to make my code works.
My system() command don't seems to work.

for that code :

$res = system($command);
echo"res = $res<br>";

the result is "res = " and the command is not executed.

I feel that it come from my Apache configuration.
However my safe_mode_exec_dir is pointing on the dir of my exec code. My OS is Unix.

Php Command Line
how would I write a function so that it can accept parameters when running it via command line?

eg.

php -q email-script.php

and somehow pass an email address to that file?

is it possible to have the php file wait for keyboard input?

Command Line
Is it possible to execute PHP from the command line, like PERL? I know PHP, and not PERL, I know they are similar but it would be easier if I didn't have to learn a second language just yet.

How To Use Php On The Command Line?
My question is how to use php on command line in windows

Command Line Or Not???
What's the best way to check whether script is run from command line or by
web server?



PHP Command Line
I am running PHP from the command line, so I can have a huge loop, so... how can get the file to start over once it gets to the end of an array? after the foreach, I was thinking of having:

<?php
header("Location: contentRobot.php");
exit;
?>

But... I'm not sure if that is only valid for browser or not.

PHP Command Line (php.exe)
I am running WAMP Server on my computer, and I need to run a script with the PHP Command Line Interface... I've been doing some research and  so I tried entering the folowing command into the php command window: php -h, that is supposed to show a list of commands... nut it does nothing... nothing I try works... any ideas?

Just One Line ! (exec Command)
I would most like to just get the first line from exec result. The last line just isn't what I want. When I use passthru it doesn't allow me to store the results in a variable, so that's no good.

Skip To Line Command?
Hello fellow PHPers. I've made a few posts in the past few days and really appreciate your help. Now i'm at the end of my project - getting a database submission/send email form to validate.

I get all the correct errors if the person doesn't enter certain fields, and the data doesn't submit. If they do enter all the required fields, it submits...

However, the code for when it doesn't submit reads...
if ($errmsg!= "") {
echo $errmsg;
} else {
the rest of the code
the rest of the html syntax

My problem is that if the error page comes up, the rest of the HTML doesn't get rendered because the PHP simply quits. Is there a command in PHP in terms of "Go To Line This in the document", so rather than exiting it would just skip the rest of the PHP but still print all the HTML. I thought of switching!= to == but the way in which that works fails as well. I'm thinking I might have to validate straight on the form rather than the submission page, but let me know what you know!

Talking To The Command Line
I have written a c program using Baltimores Encryption solution. I need to be able to access the executable from PHP but have not got the first clue how...
I simply need to pass the executable a string, and expect a string back. The whole function works on the command line, but, AGGHHH, how to i integrate it into PHP...
this is why i love ASP and COM URL.

Command Line Problems
I'm trying to use PHP as a command line executable, but I'm running into a few problems with passing in arguments, mainly, I can't.

I am using PHP version 4.2.3 and I have installed it with --enable-cli. I can run PHP scripts from the command line, no problem. However, no matter what I try, I can't seem to pass in variables and print out their values.

Newbie: How To Run Php From Command Line?
I need to test a script and want to do so on a Linux box (logged in via SSH from
another machine).

I tried creating a test script (called "test.php") like this:

#!/usr/bin/php
<?php
print "test";
?>

and tried running this from the command line like this:

../test.php

but nothing happens.

I also tried this:

../test test.txt

and the text in test.txt is this:

X-Powered-By: PHP/4.2.2
Content-type: text/html

Why is "test" not appearing in the test.txt file?

How do I get "test" to appear on my screen, rather than having to use test.txt?

Do I have to redirect STDOUT? How do I do this?


Command Line Tool
How do I get php to run a command line tool, in Windows Server 2003, and the
continue with the job in hand, is this possible?

Compiling Command-line
I'm trying to install a program (Cacti -- it queries for things like bandwidth usage, etc. every five seconds, and generates graphs from that data); however, it requires that it be able to run "php" from the command-line. (As opposed to through Apache.)

Is there an easy way to recompile PHP with its previous settings, but also configure it to allow me to invoke it from the command line? (If it matters; I compiled it initially with ApacheToolbox, but that's of no help to me for this.)

Running PHP From Command Line
I just installed the latest version of PHP as an Apache Module. I'm wondering, how can I now run PHP from the command line? I heard there was a way without having to reinstall PHP to do this.

Command-line PHP Problem
I am trying to simply pipe in 2 very small commands and not have to
create a PHP script to do this:

Quote:

PHP Only Runs From Command Line
I know very little about PHP, but I was just curious to know
why exactly would some PHP code run fine from the command line but not
from the browser?

I'm just curious. I was working with someone else's PHP code that
supposedly created MySQL tables in a database and for some reason it
just wouldn't create the tables at all (no specific error message).
Someone suggested I run from the command line and when I did, it
worked...

PHP And Command Line (for Wiki)
I started to "program" in PHP (better say to read it :P) from a
few days because I am installing a Wiki on a virtual server (Windows
Server 2003 with Plesk 7.6). I have PHP5 and all is working just fine.

However, I am trying to parse latex equations and encountered some
troubles. I have already installed all the necessary software and when
I execute the following by command line:

C:miktexinlatex.exe --output-directory=C:Inetpubvhostsmysite.com
httpdocswikiimages mp --interaction=nonstopmode C:a.tex

I generate the right file in the right folder. However, when I try to
execute (adding it to a PHP routine that is executed for sure):

$command = "C:miktexinlatex.exe --output-directory=C:Inetpub
vhostsmysite.comhttpdocswikiimages mp --
interaction=nonstopmode C:a.tex";
$text = exec($command);

Running Php From Command Line
I'm trying to run a php script from the command line, but I'm having some difficulties. If I browse to my page in IE, my script executes properly, but if I run it from the command line, I receive this error:

Warning:  fopen() URL file-access is disabled in the server configuration in /www/public_html/update.php on line 21

Warning:  fopen(): failed to open stream: no suitable wrapper could be found in /www/public_html/update.php on line 21

I'm not sure why I receive errors when trying to run on the command line and not when accessing the page through a browser... My question is, can I open the page from a command line like a browser would??? I would like to make it a cron job, and currently I try "php update.php", but that receives the error... Is there a "http update.php" or a "get update.php" that would potentially do the same thing as a browser?

Reading From Command Line
I want to be able to have an infinite loop that is exited when the user types "q" on the command line. This is pretty trivial:

while(1)
{
    if (trim(fgets(STDIN) == "q")
    {
         exit;  }}


The loop however holds and waits for user input. I searched the php.net site and in the user comments I found this function: Code:

PHP Command Line Called Via Exec();
If I enter the following at the command line, I
successfully get an email sent to the correct name/email:

php /var/www/html/admin/adminscripts/welcome-cli.php
'Me' 'me@me.net' ....

Mysql Command Line Client
Is there any way of making the mysql command line client full-screen?
Sometimes it's easier to use the client than go thru php, but
since it's only about 80 characters wide that limits its usefulness.

Disable Command Line Arguments For Php-cli
i have been trying to disable the -n and -c arguments that you can use with php from the command prompt. this is because these features can effectively disable my php.ini which has a whole mess of disabled_functions (that i want to ensure remain disabled).

my best idea for going about doing this so far has been to download the source for the newest php, with hopes to compile my own which will ignore arguments other than a filename. so far the closest i have got is to the the zend_API.c which has the follow function: Code:

Segmentation Fault On Command Line
I have a script running in the wee hours via cron job. When I access the
script via browser it works like a charm. I noticed it was not succeeding
and ran it manually from the command line and it threw a Segmentation Fault.

Googling produces a ton of information on this subject but al of specific to
certain binaries and it doesn't seem germaine to solving my problem.
<?
mysql_connect('mysql.example.com', 'example', 'example');
mysql_select_db('example');
mysql_query("DELETE FROM aniSessionLog WHERE timestamp < NOW() - 900");
$rows = mysql_affected_rows();
mail('jg@example.com', 'cleaned Intranet DB', "$rows rows deleted.");
?>

Query About Command Line PHP Execution
I want to know how to execute php file from the command line.I knwo that we can do via " PHP sample.php". But if I want to send any parameters to my sample.php how can i achieve ..

MySQL Database From The Command Line
I am creating a MySQL database from the command line for the first
time. I am creating a database called 'goldminers' with 1 table called
'goldminers'. What am I doing wrong here:

mysql> use goldminers
Database changed
mysql> drop table goldminers
-> ;
Query OK, 0 rows affected (0.13 sec)

mysql> make table goldminers
-> (id int unsigned not null primary key,
-> name char(30) not null,
-> dateIssued date not null,
-> location char(20) not null,
-> comment text null,
-> url text null);
ERROR 1064: You have an error in your SQL syntax near 'make table
goldminers
(id int unsigned not null primary key,
name char(30) not n' at line 1

The reason that I didn't make the ID auto_increment is that, even
though it is generally incrementing by 1 every time, there are some
places where the database skips numbers because of goldminers who we
don't have any information on. I need my database's IDs to match the
IDs on the existing paper-version of the database.

Command Line On A Linux Machine
how I can run a PHP script from the command line on a linux machine.

Passing Parameter In Command Line
Can somebody tell me how can I pass a parameter to a PHP script in de command line?
for instance: bin]# ./print_listname 18

<?php
//$list_number = // parameter var;
echo $list_number;?>

Running PHP On Command Line & IIS Setup
I am trying to run PHP off of a IIS server....which hasn't be so pretty. I have included the path environment variable C:PHP, rebooted and started back up. Within C:PHP are two executables php-cgi.exe and php-win.exe. everything I have read online has said that all I need to do is point an environment path to this folder and everything should work. wrong!!!!

I try to run a script in dos and get php is not valid command error.....it's as if it isn't recognizing the command path. I have also set up php under properties to be opened by the CLI....so what am I doing wrong here? I'm running IIS 6 with a dedicated server.

Sed Command Fails If Line Has Quote
I'm trying to make a script that will search a list of files and remove
the following line

<meta http-equiv="Content-Type" content="text/html; charset=<?php echo
CHARSET; ?>">

I'm doing this by generating a sed command and using system to execute
it like so:

$t = sprintf("%s "s/<meta http-equiv="Content-Type" content="text/html;
charset=<?php echo CHARSET; ?>">%s/g" %s >%s", $sedPath,$str1_rpl,
$infile, $outfile);
system($t);

The problem is the quote found in the text to be replaced. sed sees it
as part of its command and ignores everything after it. For example, if
I use
<meta http-equiv="Content-Type" content=

for the search string, it works. But if I use
<meta http-equiv="Content-Type" content="

it doesn't work. I have tried escaping the quote

Php Designer 2007 Command Line
In windows XP, I want to be able to click on a .php file and have it
opened in PHP Designer 2007,
Or right-click on it and have an "edit" menu option presented to me.
I know how to tweak the registry to do this in general, but what would
the command line look like in this specific case ?

Invoking Dompdf Via The Command Line
A little question, what i can use dompdf via command line?
The syntax is:

$ php -f dompdf.php -- [options]

Can any explain me the meaning and the usage? I must pass a file .htm

Command Line PHP: Installing On Debian
I have installed PHP4.3.10 Apache2 module (on Debian linux) and my PHP
scripts work fine accessed via a browser.

What extra do I need to install to get PHP to work from the command
line?

Quote:

[windows] PHP.GTK And Popuped Command Line
i compile php.gtk file with roadsend php compiler. Is here possiblity to
have windows program without starting command line window?

Speeding Up Command Line Scripts
I have a command line script which works really fine, the only problem
is that it take *really* long for the first output to be printed on
screen.
Since I also get some HTTP headers I'm suspecting that some sort of
output buffering is used.
How can I tell PHP to flush the buffer automatically (without using
flush(); after every print or echo) and to remove the headers?

Command-line PHP And Suppressing Headers - Help
How do I suppress the lines PHP normally delivers to stdout (your browser)
if I am doing command-line PHP?

e.g.

stuff.php:

<? echo 'Hello World' ?>

Calling it from a Red Hat 7.3 command-line terminal I would do the
following:

php /my/directory/path/to/stuff.php

And I would eventually get

Hello World

But before that, an enormous amount of garbage, particularly HTTP header
information:

PHP Version 4.2.3
Content-type: text/html
Hello World

How do I strip everything out except that which I need to see while using
PHP from the command line? I am having a horrific time using TCL instead.

Syntax Check On The Command Line
It would be great if anyone could help me with this problem:
I want to check the syntax of my php code. Therefore I use the command
line function PHP -l, the structure is similar to the following code
(example from the php Manual.) The Problem is: I read from the standard
output with
echo stream_get_contents($pipes[1]);
this function is available only from PHP version 5, but I must write
for version 4.3.0. Which way could it be solved? I don't want to use a
temporary file.

<?php
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will
read from
1 => array("pipe", "w"), // stdout is a pipe that the child will
write to
2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file
to write to
);

$cwd = '/tmp'
$env = array('some_option' => 'aeiou');

$process = proc_open('php', $descriptorspec, $pipes, $cwd, $env);

if (is_resource($process)) {
// $pipes now looks like this:
// 0 => writeable handle connected to child stdin
// 1 => readable handle connected to child stdout
// Any error output will be appended to /tmp/error-output.txt

fwrite($pipes[0], '<?php print_r($_ENV); ?>');
fclose($pipes[0]);

echo stream_get_contents($pipes[1]);
fclose($pipes[1]);

// It is important that you close any pipes before calling
// proc_close in order to avoid a deadlock
$return_value = proc_close($process);

echo "command returned $return_value
";
}

?>

PHP Execute Command Line Prog
Is there a cleaner way to execute a command line php script from within a web accessed php script? Im currently using exec("php foo.php"); but it seems like there should be a better way.

Running Script From The Command Line
I'm trying to set up email piping on my server and I'm getting the following error back in my email:

/bin/sh: /var/www/vhosts/example.com/httpdocs/mailcontroller.php: /usr/bin/php
: bad interpreter: No such file or directory

I think the mail alias I set up in qmail is working correctly because when it wasn't I didn't get a script error back, just a user not found error.

From the error it sounds like it's not able to find php but I've tested a script from the command line to that path and it works fine (php is running as CGI btw, rather than CLI). I'm guessing that it's making it all the way to mailcontroller.php because I don't have the /usr/bin/php path anywhere else but in that file.  Could it be that it's actually running the script but can't get to stdin?

Connect To PEAR With Command Line
I have recently installed PEAR to my base directory next to my website which wasn't a problem (i hope). What i need to do now is install the BBCodeParser package.

I need to know how to install this package using the command line.  Do i use the command prompt on my PC and if so how do i connect to the web server which is on a host not stored locally.

Running PHP Scripts From The Command Line Under Windows
I was wondering if anyone has ever tried running PHP scripts from the DOS command prompt. Any insight would be appreciated.

Php Script Behaves Differently When It Run In Command Line
I found that the php script behaves differently when it run in command
line rather than runing over web server.

Program includes the code like:

<?php
function send_email($from_address, $to_address, $bcc_address,
$subject, $msg, $attachments,$reminder_id) {
$headers = ...;
....
mail($to_address, $subject, $msg, $headers);
...
}

#main body of code here to grap info from database and call
send_mail() function here
...
send_email($newarry[FROM_ADDRESS], $newarry[TO_ADDRESS], $newarry
[BCC_ADDRESS], $newarry[SUBJECT], $newarry[BODY],$attachments,
$newarry[ID]);

?>
I can not use lynx since it doesn't support https on my machine.
The values are from database and feed in send_mail() function which
will form the body message and header and pass to php mail()
function. The problem is that "mail($to_address, $subject, $msg,
$headers)" can not access the values passed over to it when i use
'php' command to run the script. But I can use 'print' to print out
all the values but mail()function just can't get them.
However, this program works fine when I use broswer to access it.

Check Php Config From Linux Command Line?
Is there any way to check the setup of a php install (in particular, the
installed extensions, eg mbstring) from the Linux command-line ie *without*
using a phpinfo page?

If it makes any difference, I'd like to do this on both Fedora and Gentoo.

Popen - Command Line Vs. Web Server Performance
say i have the following two php scripts:

ptest.php:
<?
$p1 = popen("c:phpphp -q hello.php","r");
$p2 = popen("c:phpphp -q hello.php","r");
while (!feof($p1))
print fgets($p1);
while (!feof($p2))
print fgets($p2);
pclose($p1);
pclose($p2);
?>

and

hello.php:
<?
print "hello,
world!
";
?>

when i run ptest.php via the command line (ie. by typing in c:phpphp
ptest.php at the dos prompt) it runs instantly.

when i run ptest.php via a webserver, the resultant page not only
doesn't even load - it results in a bunch of errors (that appear as
dialogue boxes on the machine doing the hosting) effectively saying
that the command failed to execute properly and will now be shut down.
after clicking through all the errors, the systems performance is
noticebly affected (and in fact is bad enough such that i think a
reboot is justified).

Output Shown Only In Command Line And Not In Browser
I have the following code in a script
--------------------------------------------------------------------------------------------------------------------------------
foreach($serverlist as $sno=>$serverdata) {
$servername = $serverdata['name'];
if($servername) {

unset($outputstr, $outputarr);
$outputstr = exec("ssh -n ".$servername." 'fstat | wc -l'",
$outputarr);

echo
"
----------------------------------------------------------";
echo "
ssh -n ".$servername." 'fstat | wc -l' ";
echo "
servername = ".$servername;
echo "
outputstr = "; var_dump($outputstr);
echo "
outputarr = "; var_dump($outputarr);

}
}
--------------------------------------------------------------------------------------------------------------------------------

When executed from browser it displayed:

---------------------------------------------------------- ssh -n
192.168.0.155 'fstat | wc -l' servername = 192.168.0.155 outputstr =
string(0) "" outputarr = array(0) { }
---------------------------------------------------------- ssh -n
192.168.0.156 'fstat | wc -l' servername = 192.168.0.156 outputstr =
string(0) "" outputarr = array(0) { }
---------------------------------------------------------- ssh -n
192.168.0.159 'fstat | wc -l' servername = 192.168.0.159 outputstr =
string(0) "" outputarr = array(0) { }

--------------------------------------------------------------------------------------------------------------------------------

When executed from command line it displayed:

PHP Warning: Module 'ctype' already loaded in Unknown on line 0
PHP Warning: Module 'SimpleXML' already loaded in Unknown on line 0
PHP Warning: Module 'dom' already loaded in Unknown on line 0
PHP Warning: Module 'iconv' already loaded in Unknown on line 0
PHP Warning: Module 'pspell' already loaded in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/20041030-debug/ssh2.so' -
/usr/local/lib/php/20041030-debug/ssh2.so: unsupported file layout in
Unknown on line 0
PHP Warning: Module 'pcre' already loaded in Unknown on line 0
PHP Warning: Module 'xml' already loaded in Unknown on line 0
bash: fstat: command not found
Password:

Cron Or Command Line: Run A Very Long Php Script
I have a list of links which point to e.g.
thescript.php?album=somePictures1
thescript.php?album=somePictures2

This list is about 3000 links. Each album may have 500 or more pictures in it.
the script looks in the specified dir, and creates thumbnails if they are not
present. So, displaying a particular album often takes quite a while. I've set
the proper php.ini stuff to accomodate the long script_execution's. Thats all
working fine.

Now, I dont want the end user to have to wait for the thumbs if they land on an
album that has not yet had thumbnails created.

So the question is, what is the best way to run all those links automatically,
thereby creating all the thumbs?



Command Line Interface? Sending Commands?
Is there a way to send a CLI command from within PHP?

Something like "/int mplayer2 /wav /play /close c:soundshb10.wav".


Copyright © 2005-08 www.BigResource.com, All rights reserved