Kiran Kumar M wrote:

> Hi,
>
> It might be a bit out topic, but I hope experts in cgi and perl will give
> me some solution..
>
> I have the following script that execute at command prompt and working
> fine ..
>
>  perl -pi -e 's/^(user)(\s+.*)(old)(.*)$/${1}${2}new${4}/' filename
>
> For replacing the old item with the new item based on one filed (here
> user).
>
>   Is there any similar script available to execute from browser.. I wil
> pass the messages from html, so the script has to take three parameters ..
> $user, $old, $new .. and perform on "filename"

I have been doing some php work lately so in the interest of when you have a
hammer everything looks like a nail, I would use php. once you create your
form set the action to the phph page and then the form variables are
immediately available to the php script. This should be close but it depends
on what the perl return I have not tested this exact scenario.

<html>
<head>
<title> my perl script caller page</title>
</head>
<body>
<?php

 if (`perl -pi -e 's/^($user)(\s+.*)($old)(.*)$/${1}${2}$new${4}/'
$filename`){  #these are back ticks of course
    print "processing for user $user completed successfully" ;
}
else{
    print " there was a problem in the perl script<br>\n";
    print "the variables used are:<br>user : $user<br> old: $old<br>new:
$new<br>filename: $filename<br>\n";
}
?>
</body>
</html>

this should be close.

you can also print the ourput from the perl with
print `perl command here`;

or you might have to assign it to a vraible before printing :
$output=`perl command`
print $output;

of course you will need th e php modues installed but that is another story.

HTH
Bret



_______________________________________________
Redhat-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-list

Reply via email to