Greetings to all. I have run into a wall and I cannot climb it so I am looking for someone with some rope, LOL.
I have a script (a few), that is consisting of a PHP backend that I am trying to use a system, exec, passthru or maybe even a proc_open, which one ever best fits my issue (not sure at this point, even with reading php.net) I also have a front end containing PHP, Smarty a little jscript that passes a variable from a text input box to the PHP backend to execute a the command from the text input box. Here is where it gets a little tricky. I also have a perl script that when used from the commandline in Linux will create a svn branch task. It is a helper. so if I am at the commandline in Linux and type svn branch TASK_0000_MY_TASK, it will create an svn task in the dev directory (not really important where it creates it) it does but when this is typed from the command line it does this which takes about 4 seconds.
me@my-desktop:~/dir/php/html/thisplace$ svn branch TASK_2001_My_Test
Committed revision 82856.
-- Created new task - source:thisplace/dev/tasks/TASK_2001_My_Test
This is what is done from the command line which is done via the perl script I talked about. svn has an alias that points to this perl script. With that said I have a front end script that looks like this:
<form method="POST" action="index.php?Page=MyPage">
<input type="hidden" id="Page" name="Page" value="MyPage" />
<table cellpadding="2" cellspacing="1" border="0" class="ltGreydkGreyBorder" align="center" width="850px">
<tr>
<th colspan="4" class="coloredCenterLabel">Create a Task:</th>
</tr>
<tr>
<th style="width: 200px; text-align: right;">
New Task to Create:
</th>
<td>
<input id = "NewTask_Name" name = "NewTask_Name" type = "text" style = "margin-left: 8px; width:200px"/>
</td>
<th>
<input class="ltGreyDkGreyBorder" type="submit" name="action" value="Create Task >>">
</th>
</tr>
<tr>
<th></th>
<td style="width: 200px; font-size: 8px" align="center">must be formatted like "branch task name"</td>
<th></th>
<tr>
{if $strNewTaskView}
<tr>
<td colspan="1">
<blockquote>
<br>
<br>
<span class="boldTitle">Return Info:</span><br>
<br>
</blockquote>
</td>
<td>{$output}</td>
</tr>
{/if}
</table>
</form>
This passes the NewTask_Name as the text input to the PHP backend which looks like this:
function mTaskCreator()
{
$strAction = $this->_objUserContext->mGetPostVar( 'action' );
if( 'Create Task >>' == $strAction )
{
$this->_objUserContext->mSetViewVar( 'strNewTaskView', true );
$NewTask = $_POST['NewTask_Name'];
system("$NewTask, /home/me/place/bin/perl.pl", $output);
echo $output;
}
}
Now I am trying to pass the text entry to the perl script and hav it execute the perl and create the task. right now I am getting a 1 or a zero for the echo on $output when I click submit but the task is not in the svn task list. I get zero if I put nothing in the text box and a 1 if I put anything in it. Now here is the perl script which is long and I am pretty sure there is only two parts I need from it. which I will put here and if we need the full perl script we can do that.
#! /usr/bin/perl
package BIC::Bsv;
use Getopt::Std;
use vars qw/ %opt /;
use strict;
use DBI;
sub new
{
my ($class) = @_;
# Create a new object
#------------------------
my $self = {
strConfigFile => undef,
_strErrorMsg => undef,
strPath => undef,
strRepo => undef,
strTask => undef,
Verbose => 0,
Prompt => 1,
svnVersion => undef,
strServerRoot => 'https://sat-svn1/svn/sysdev',
};
bless $self, $class;
# Return the new object
#------------------------
return $self;
}
sub mGetInput()
{
my ($self,$strMsg) = @_;
print " -- $strMsg: ";
return <STDIN>;
}
#------------------------------------
# Output to stdout
#------------------------------------
sub print() {
my ($self, $strMsg) = @_;
print "-- $strMsg\n";
}
#------------------------------------
# Quote the arguments passed to perl
# ---------------------------------------
sub mQuoteArgs(){
my ($self) = @_;
my $count=0;
for ( my $i=0 ; $i < scalar @ARGV ; $i++ ) {
if($ARGV[$i] =~ / /) {
$ARGV[$i] = "\"$ARGV[$i]\"";
}
}
return;
}
# ---------------------------------------
# Create a new branch from /trunk
# ---------------------------------------
sub mCreateBranch(){
my ($self, $strTask) = @_;
# Figure out what repo we are working in. ( appcode or webcode )
$self->mParseCurrentPath() or $self->mExitWithError();
# If no task name was supplied
if( $strTask eq "" ) {
$self->mSetError("No task name provided with branch command");
return 0;
}
if( $self->mPathExists( "$self->{strRepo}/dev/tasks/$strTask" ) ) {
$self->print("NOT CREATED $self->{strRepo}/dev/tasks/$strTask already exists");
return 0;
}
system "svn copy $self->{strRepo}/dev/trunk $self->{strRepo}/dev/tasks/$strTask -m 'Made copy of trunk'";
$self->print("Created new task - source:" . $self->mShortPath("$self->{strRepo}/dev/tasks/$strTask") );
return 1;
}
Now remember this is not the full perl script, sorry it is 1500 lines long. I hope this helps with an answer I am at whits end.
Thank you people of PHP builder