Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

'unexpected operator' error

Status
Not open for further replies.

DaveC426913

Programmer
Joined
Jul 28, 2003
Messages
274
Location
CA
I've got a php file calling a PERL script which is turn calling a shell script.

I believe it's the PERL script that is throwing the following error:

[Wed Mar 15 10:29:09 2006] [error] [client 216.7.222.41] [: event: unexpected operator, referer:
I get the referer bit, what I'm not sure about is what it's telling me. I don't know how to "parse" the middle bit:

[: event: unexpected operator,


Is there anyything here that hints at what the unexpected operator is? I can't tell if '[:' or 'event' is a piece of my code or what. The only reference to 'event' in the PERL script is this:

if ($mode eq "event")


I can post the code if you feel like looking yourself, but really i'm jusdt asking how to interpret that bit of message.
 
To figure out what the error is comming from I would run all 3 by themselves.

First run the shell script. Do you get an error?
Then run the perl script. Do you get an error?
Then the php file.

But it sounds like Perl or Shell. Post the code if you want.
 
...run all 3 by themselves..."

I wish it were that simple. I'm reverse-engineering old code, and there's lots of tie-ins and connections I don't understand yet.

Here's the PERL script, below that is the shell script.


#!/usr/bin/perl -w
###############################################################################
use strict; # Activate compile-time syntax checking
use CGI; # Needed for CGI environment
use CGI::Carp qw(fatalsToBrowser); # Throw errors as HTML pages
use File::Copy; # Much easier for duplicating the sample conf

###############################################################################
# Initialize CGI and set expected parameters
###############################################################################
my $thecgi = new CGI;

# the arg container for the shell script
my ($instructions,$redirect,$code,$clientDB,$clientName,$eventID,$eventName,$mode);
# these are expected in either case
$mode = $thecgi->param("mode");
$clientDB = $thecgi->param("clientDB");

# container for args, make the default mode 'client'
if ($mode eq "client")
{
# take care of webalizer config file
$clientName = $thecgi->param("clientName");
newClient();

$instructions = "$mode $clientDB";
$redirect = "}
# if it is for a new event, add the eventID
if ($mode eq "event")
{
# update webalizer conf file
$eventName = $thecgi->param("eventName");
$eventID = $thecgi->param("eventID");
newEvent();

$code = $thecgi->param("c");
#debug
$instructions = "$mode $clientDB $eventID";
#$instructions = "./test.sh";
#$instructions = "./createdir.sh $mode $clientDB $eventID";
$redirect = "}

###############################################################################
# Call the shell script with instructions
###############################################################################
#debug
my $cmd = "./createdir.sh $instructions";
#my $cmd = ($instructions);
my $result = system($cmd);
$result >>= 8; # shift 8 bits
#debug
print $result;
if ($result > 0)
{
printError("The createdir shell script failed: '$result'");
}
else
{
select (STDOUT);
print $thecgi->redirect( $redirect );
exit 0;
}


################################################################################
# Webalizer config file subroutines
################################################################################
# Set up a new client.
################################################################################
sub newClient
{
# first we need to create the target directory for stats
my $statdir = "<path>/$clientDB";
system ("mkdir -m 775 $statdir");

# prepare the client-specific conf file entries
my $outputDir = "OutputDir $statdir\n";
my $reportTitle = "ReportTitle Usage Statistics for $clientName\n";

# duplicate the default conf file
my $basefile = "<path>/client.sample.conf";
my $newfile = "<path>/$clientDB.conf";
copy ($basefile,$newfile);

# open and append to the new conf file
open (NEWCONF, ">> $newfile")
or die printError("Could not open $newfile for writing: $!");
flock (NEWCONF, 2);
select (NEWCONF);
print "$outputDir";
print "$reportTitle";
close (NEWCONF);
}

################################################################################
# Set up a new event.
################################################################################
sub newEvent
{
# prepare the grouping directives for the event
my $includeURL = "IncludeURL /$clientDB/$eventID/player.php*\n";
my $groupURL = "GroupURL /$clientDB/$eventID/player.php* $eventName\n";
my $hideURL = "HideURL /$clientDB/$eventID/player.php*\n";

# confirm the conf file exists
my $newfile = "<path>/$clientDB.conf";
open (YO, "< $newfile")
or die printError("Could not open $newfile for reading: $!");
close (YO);



# open and append the new event to the conf file
open (CONF, ">> $newfile")
or die printError("Could not open $newfile for writing: $!");
flock (CONF, 2);
select (CONF);
print "$includeURL";
print "$groupURL";
print "$hideURL";
close (CONF);
}
################################################################################


###############################################################################
# printError() - print error message
###############################################################################
sub printError
{
my $em = shift;

print $thecgi->header();

print<<EOF;
<center>
<table border=0 bgcolor="#c0c0c0" cellpadding=0 cellspacing=0>
<tr>
<td>
<table border=0 width="100%" cellpadding=5 cellspacing=1>
<tr">
<td bgcolor="#311C52" width="100%">
<font color="#ff0000"><b>Error -</b></font>
<font color="#ffffff">$em</font>
</td>
</tr>
<tr>
<td>Please contact OBC sysadmin and report the error shown above."</td>
</tr>
</table>
</td>
</tr>
</table>
</center>
print $cmd;
EOF
;
}
exit 0;




Shell:


#!/usr/local/bin/bash


BASE_PATH="<path>/htdocs/"
REMOTE_PATH="<path>/htdocs/"

# the first arg is essential since it defines what is to be done
if [ -z $1 ]
then
echo "Usage: `basename $0` [client|event] [client] [directory]"
exit 0
else
mode=$1
fi

# the mode is used to setup the directory needed
if [ "$mode" == client ]
then
THISDIR=$2
fi

if [ "$mode" == event ]
then
BASE_PATH=$BASE_PATH/$2
THISDIR=$3
REMOTE_PATH=$REMOTE_PATH/$2
fi

# the commands are executed using the variable as set above
# make the directory here on staging
mkdir -m 775 $BASE_PATH/$THISDIR
#mkdir -m 775 ./$THISDIR

# now sync <serverpath> so the directory is replicated there too
#rsync -aze ssh $BASE_PATH/ --include $THISDIR --exclude "*" <path>:$REMOTE_PATH/
rsync -aze ssh $BASE_PATH/ --include $THISDIR --exclude "*" <path>:$REMOTE_PATH/

#exit 0
 
seems there is an operator, maybe '<' or '>' where it should not be?
 
Try logging the values of your $instructions variable to see what's coming from the php script, and see what's going to the shell script

<path>:$REMOTE_PATH/ <-- is this normal syntax are you just protecting your script?

HTH
--Paul


Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
<path>:$REMOTE_PATH/

Anywhere you see '<path>' that is me obscuring the actual path. Anything other than that, is real code, such as ':$REMOTE_PATH/'

Sorry, that was dumb of me not to specify.

 
Oh, something else that will give you some context: the reason this is a bit complicated is that this code has been ported to another system for development. All I'm doing so far is getting it running on this new Development server. (It runs poorly at best on the Production server, so we're porting it to a new one, but doing development on it before we go live.)

The new system is NOT identical to the old one. eg. Moving to PHP5 from 4.10, so that's something I'll have to straighten out (yes, we've switched off the implicit Global variable setting for now).
 
After that statement, you nned to know what was different .... server audit time ;-)

Paul
------------------------------------
Spend an hour a week on CPAN, helps cure all known programming ailments ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top