You are here: Command fails if I use variable instead of string constant « PHP Programming Language « IT news, forums, messages
Command fails if I use variable instead of string constant

Posted by qazwart on 07/18/07 22:26

I am reading from a "cvs rlog" command, and I need both the STDOUT and
STDERR. Unfortunately, something very strange is happening. If I do
this:

$cmd = "$cvs_cmd -q rlog -NS -r$from_label::$to_label neo 2>&1"; //
Hard coded module
DEBUG ("if (!($cvs_fh = popen(\"$cmd\", 'r'))) {");
if (!($cvs_fh = popen("$cmd", 'r'))) {
generate_error("Canot open command \"$cmd\" for reading");
}
$exam_file_flag = false;
$inside_revision_flag = false;
$inside_comment_flag = false;
print "Generating Initial Release Information: ";
flush();
while($line = fgets($cvs_fh)) {
DEBUG ("....line = \"$line\"");

I get the combined STDOUT and STDERR in my while loop. However if I do
this:

$cvs_module = "neo"
$cmd = "$cvs_cmd -q rlog -NS -r$from_label::$to_label $cvs_module
2>&1"; //Use variable for module
DEBUG ("if (!($cvs_fh = popen(\"$cmd\", 'r'))) {");
if (!($cvs_fh = popen("$cmd", 'r'))) {
generate_error("Canot open command \"$cmd\" for reading");
}
$exam_file_flag = false;
$inside_revision_flag = false;
$inside_comment_flag = false;
print "Generating Initial Release Information: ";
flush();
while($line = fgets($cvs_fh)) {
DEBUG ("....line = \"$line\"");

I don't get STDERR in my while loop.

Note the "DEBUG" line. This is a little routine I wrote to help me see
what is going on. Here is the output of the DEBUG line in the first
code example:

DEBUG: if (!( = popen("/usr/local/bin/cvs -d :pserver:build@aladdin:/
tools/CVSROOT -q rlog -NS -rNEO-199::NEO-210 neo 2>&1", 'r'))) {

Here is the output of the "DEBUG" line in the second code example:

DEBUG: if (!( = popen("/usr/local/bin/cvs -d :pserver:build@aladdin:/
tools/CVSROOT -q rlog -NS -rNEO-199::NEO-210 neo 2>&1", 'r'))) {

Is there something I should be looking for?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация