LinuxQuestions.org
Help answer threads with 0 replies.
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-26-2007, 05:01 PM   #1
ciscotech6509
LQ Newbie
 
Registered: Jun 2007
Posts: 4

Rep: Reputation: 0
PHP parse/syntax error?


My script is as follows:

<?php

$MYCFGMAKER_File = '/usr/etc/mrtg/mrtgd/bin/mycfgmaker';
$IP_Address = $_GET['ipaddress'];
$Community_String = $_GET['communitystring'];
$Poll_Interval = $_GET['pollinterval'];
$CFG_File = {$IP_Address}.cfg
$Execution_Code = <<<CODE
$MYCFGMAKER_File --ifref=name --ifdesc=descr --show-op-down --noreversedns --global 'PageTop[^]:<~--#include virtual="/header.html" -->' --global 'IconDir: /mrtg/gifs/' --global 'WriteExpires: Yes' --global 'Options[_]: bits' --global'WorkDir: /usr/local/httpd/htdocs/mrtgd-data' --global 'PathAdd: /usr/local/rrdtool/bin' --global 'LibAdd: /usr/local/rrdtool/lib/perl' --global 'LogFormat: rrdtool' --global '14all*maxrules[_]: 1' --global 'routers.cgi*Icon: cisco-sm.gif' --global 'WithPeak[_]: ymw' --global 'Interval: {$Poll_Interval}' --output=/usr/etc/mrtg/mrtgd/new/{$IP_Address}.cfg {$Community_String}@{$IP_Address}
CODE;

print 'PHP has assigned the variables and they are as follows:\n';
print "\nIP Address = $IP_Address\n";
print "SNMP Community String = $Community_String\n";
print "Polling Interval = {$Poll_Interval}min\n";
print "\n PHP will now attempt to run the MRTG \"mycfgmaker\":\n";
print "EXECUTING . . . $Execution_Code";

if (file_exists($MYCFGMAKER_File)) {
print "\"mycfgmaker\" exists, and will now attempt to gernerate your devices cfg file\n";
if (file_exists($CFG_File)) {
print "ERROR: {$IP_Address}.cfg already exists, and will not be overwritten!"
} else {
$cmd = $Execution_Code;
system($cmd,$return_value);
($return_value == 0) or die("returned an error: $cmd");
}
} else {
print "ERROR: \"mycfgmaker\" cannot intiate or does not exist. Please contact the server administrator.";
}

?>



When I run the script show above, I get a parse error on Line seven. Is there something with my code because as far as I know it should work.
 
Old 07-26-2007, 05:41 PM   #2
ciscotech6509
LQ Newbie
 
Registered: Jun 2007
Posts: 4

Original Poster
Rep: Reputation: 0
I have corrected this issue by changing line 7 to read:

$CFG_File = $IP_Address.cfg

Now, I am recieving a parse error on line 8. I have tried changing the syntax of line 8 to the following:


$Execution_Code = "$MYCFGMAKER_File --ifref=name --ifdesc=descr --show-op-down --noreversedns --global \'PageTop[^]:<~--#include virtual=\"/header.html\" -->\' --global \'IconDir: /mrtg/gifs/\' --global \'WriteExpires: Yes\' --global \'Options[_]: bits\' --global\'WorkDir: /usr/local/httpd/htdocs/mrtgd-data\' --global \'PathAdd: /usr/local/rrdtool/bin\' --global \'LibAdd: /usr/local/rrdtool/lib/perl\' --global \'LogFormat: rrdtool\' --global \'14all*maxrules[_]: 1\' --global \'routers.cgi*Icon: cisco-sm.gif\' --global \'WithPeak[_]: ymw\' --global \'Interval: $Poll_Interval\' --output=/usr/etc/mrtg/mrtgd/new/$IP_Address.cfg $Community_String@$IP_Address";


However I am still receiving the parse error. Is there a syntax error here, and why doesn't the heredoc coding style work?
 
Old 07-27-2007, 02:22 AM   #3
danaketh
LQ Newbie
 
Registered: Jul 2007
Location: Czech Republic, Prague
Distribution: Debian (stable)
Posts: 25

Rep: Reputation: 15
you have missing ";" on line 22

Code:
print "ERROR: {$IP_Address}.cfg already exists, and will not be overwritten!";

Last edited by danaketh; 07-27-2007 at 02:23 AM.
 
  


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
What's the meaning of "PHP Parse error: parse error, unexpected $ in..." frandalla Programming 23 03-04-2009 12:34 PM
PHP parse error in config.inc.php.in Confusedious Linux - Software 2 11-03-2005 05:08 AM
PHP parse error unexpected '>' ldp Programming 2 03-04-2005 02:20 PM
PHP Parse error.....PHPBB bentman78 Linux - Software 0 07-09-2003 06:35 AM
php parse error wujimon Linux - Software 4 03-26-2003 02:37 PM

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

All times are GMT -5. The time now is 04:17 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