Sending a response header to php script

Hi, 'sperts!

I have inherited a subscription based site that uses both php and perl/cgi for user management. I have a php script that will post to a cgi/perl script that searches for a specific username. The current perl script simply prints out the results. What do I add to the perl script so that it sends the result variable back to my php script?

The perl script is:

$name = `cat /path/to/my/list|grep -i "(results from form)"`;
$name =~ s/\n/<br>/ig;
print $name;

What do I need to change the "print $name" so that the result is sent (GET is fine) to a php script? Something like in php:

header("Location: http://www.mysite.com?name=results/");
admashAsked:
Who is Participating?
 
Perl_DiverCommented:
if this is all the perl script does:

 $name = `cat /path/to/my/list|grep -i "(results from form)"`;

you could just do that in your php program using the appropiate php syntax for capturing output back from the shell. The above line is doing just that:, returning the value from the operating systems cat and grep functions.
0
 
Perl_DiverCommented:
$name = `cat /path/to/my/list|grep -i "(results from form)"`;
$name =~ s/\n/<br>/ig;
print "Location: http://www.mysite.com?name=$name\n\n";

does $name really contain html code in it?
0
 
admashAuthor Commented:
No, there is no html present in $name, obviously there is a lot of cleaning up I need to do to the code. I am inexperienced with perl, however. I have been using php for a while now.

What I am getting is:

Location: http://www.mysite.com?name=all of the results

in my browser now. what do I need to do to actually send the url?
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
admashAuthor Commented:
Let me be a little more specific:

This is what needs to happen:

checkuser.php
    This script checks current sales and finds expired accounts
    When it finds expired account, I need to see if the username is still active.
    This php script sends form info via post to findthisuser.cgi written in perl for a search
findthisuser.cgi
    Takes the POST info and searches (the script is above).
     I need this script to either return the search results to checkuser.php, OR
    send a yes or no variable to checkuser.php to let me know that the username is there or not.

Maybe that will help make some sense. This is a convoluted way to handle this, but I am working with some tight requirements as to what I am allowed to change.

All of this works great so far, but I need to change the last part of the perl script so that it sends the appropriate response back to my php script.
0
 
Perl_DiverCommented:
if you are seeing the literal words:

Location: http://www.mysite.com?name=all of the results

in the browser this means you have already printed an http header before executing the print "Location:....\n\n" command.

You may also need to uri encode $name before sending it out in the URI string.

print "Location:....\n\n";

is the same as the php function:

header("Location: http://www.mysite.com?name=results/");



 
0
 
admashAuthor Commented:
(slaps self on forehead)

$name = shell_exec('cat /path/to/my/list|grep -i "(name I am looking for)"');

It works like a charm.

That's why I like EE. You guys always take seemingly complicated things and make them so simple. I hope some of this rubs off on me!

Thanks Perl Diver for your patience, knowledge and willingness to share!

Aaron
0
 
Perl_DiverCommented:
You're welcome.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.