Issue in Integrating Perl with PHP for Windows

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
thirilog
Forum Newbie
Posts: 2
Joined: Wed Sep 15, 2010 1:57 am

Issue in Integrating Perl with PHP for Windows

Post by thirilog »

Dear friends,

I am trying to Integrate the Perl (v5.8.6) code with PHP (5.3.0) for Windows.

Objective: I have developed a perl tool to validate a CD/DVD files and would like to present this tool to the user through our interanet webserver (PHP).
Issue: Perl couldn't take the PHP argument as input!

Details:
I have placed the lnk.exe (perl tool) in localhost and triggering this exe through the below <?php?> code:

and i have passing the CD/DVD path as input argument to the Perl tool.

---PHP code---
<?php
if(isset($_POST['flcheck'])){
$path = $_POST['filepath'];
$npath = substr($path, 0, (strlen ($path)) - (strlen (strrchr($path,'\\'))));
echo "<br/>";
echo "Removed file from path path -- ".$npath;
echo "<br/>";
$result = shell_exec("lnk.exe $npath");
echo ($result);
}
?>
<html>
<head>
<title>PHP with Perl</title>
</head>
<body>
<form name="val" method="post" onSubmit="">
<table width="100%" border="0">
<tr>
<td width="17%">Browse the input path:</td>
<td width="19%"><input name="filepath" type="file" class="grid" id="filepath" maxlength="1000" /></td>
<td width="64%"><input name="flcheck" type="submit" class="grid" id="flcheck" value="File check" /></td>
</tr>
</table>
</form>
</body>
</html>

I believe the lnk.exe has been triggered and the perl can not accepting the PHP argument as input. (refer the below output from perl—when am ran the lnk.exe manually its working fine)

---PHP output---
Removed file from path path -- E:\EBook+\Development\Pearson_ebook_CD\Observatoire_4e
Error in input argument: E:\EBook+\Development\Pearson_ebook_CD\Observatoire_4e
Please try with correct input!

Any help appreciated!

Thanks in Advance,
Thirilog
thirilog
Forum Newbie
Posts: 2
Joined: Wed Sep 15, 2010 1:57 am

Re: Issue in Integrating Perl with PHP for Windows

Post by thirilog »

To ease the testing here am give the sample codes help please...

---Perl code---
$filepath = $ARGV[0];
print "Perl triggered and receiving $filepath path as argument!<br/>";
if (not(-d $filepath)){
print "\nError in input argument: $filepath<br/>Please try with correct input!<br/><br/>";
die();
}
else {
print "Perl could process with the received $filepath argument<br/>";
}

---PHP code---
<?php
if(isset($_POST['flcheck'])){
$path = $_POST['filepath'];
$npath = substr($path, 0, (strlen ($path)) - (strlen (strrchr($path,'\\'))));
echo "<br/>";
echo "After trimmed the path -- ".$npath;
echo "<br/>";
$result = shell_exec("test.pl $npath");
echo ($result);
}
?>
<html>
<head>
<title>PHP with Perl</title>
<style>
body,html{
margin:20; padding:0;
background-color:#f7f7f7;
overflow:auto;
}
label{
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-weight: bold;
color: #FF6633;
text-decoration: none;
padding-right: 8px;
padding-left: 5px;
margin-left:107px;
margin-top:20px;
}
table.grid { background:#B0C4DE; border-bottom:#5496CA solid 2px; font-size:11px; font-family:Verdana, Arial, Helvetica, sans-serif; }
table.grid input { font-size:11px; font-family:Verdana, Arial, Helvetica, sans-serif; }
table.grid tr { font-size:15px; font-size:large; font-family:Verdana, Arial, Helvetica, sans-serif; }
td { font-size:10px; font-size:small; font-family:Verdana, Arial, Helvetica, sans-serif; }
</style>
</head>

<body>
<form name="val" method="post" onSubmit="">
<table width="100%" border="0">
<tr>
<td width="17%">Browse the input path:</td>
<td width="19%"><input name="filepath" type="file" class="grid" id="filepath" maxlength="1000" /></td>
<td width="64%"><input name="flcheck" type="submit" class="grid" id="flcheck" value="File check" /></td>
</tr>
</table>
</form>
</body>
</html>

Thanks in Advance,
Thirilog
Post Reply