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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Servlet ENV Variables to a PERL program 1

Status
Not open for further replies.

lotsToLearn

Programmer
Jun 10, 1999
9
CA
Hi, <br>
<br>
I am creating a servlet that executes some thrid party CGI scripts. I have got the servlet set up so that it executes a perl, reads the results of the program and outputs it to the client. See code snippet. <br>
<br>
BufferedOutputStream out;<br>
Runtime rt;<br>
Process p;<br>
BufferedInputStream in;<br>
String s;<br>
byte[] buff;<br>
int read;<br>
<br>
buff=new byte[4096];<br>
rt=Runtime.getRuntime(); <br>
p=rt.exec(&quot;perl D:\\InetPub\\ in=new BufferedInputStream(p.getInputStream());<br>
out=new BufferedOutputStream(res.getOutputStream());<br>
while ((read=in.read(buff, 0, 4096))!=-1) {<br>
if (read&gt;0) { out.write(buff, 0, read); }<br>
}<br>
in.close();<br>
out.close();<br>
<br>
<br>
Where alh.cgi is. <br>
<br>
#!/usr/bin/perl<br>
<br>
print &quot;Content-type: text/html\n\n&quot;;<br>
print &quot;&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Missing Much Data&lt;/TITLE&gt;<br>
<br>
&lt;script LANGUAGE=JAVASCRIPT&gt;<br>
<br>
&lt;!--<br>
<br>
function _CF_checkgetquestion(_CF_this)<br>
<br>
{<br>
<br>
return true;<br>
<br>
}<br>
<br>
<br>
//--&gt;<br>
<br>
&lt;/script&gt;<br>
<br>
&lt;/HEAD&gt;&quot;;<br>
print &quot;&lt;BODY BGCOLOR='#FFFFFF'&gt;&quot;;<br>
print &quot;&lt;TITLE&gt;Unauthorized&lt;/TITLE&gt;&lt;H1&gt;You are Unauthorized&lt;/H1&gt; BLAH BLAH BLAH&quot;;<br>
print &quot;&lt;/BODY&gt;&lt;/HTML&gt;&quot;;<br>
<br>
<br>
Now incredibly, thanks to OTTO (incredible given my coding experience ) this works. However to take it to the next stage I need to pass the Environment variables to the the perl script being executed. <br>
<br>
If you know how to do this, or can offer any suggestions as to how might do this please respond. <br>
<br>
Thanks<br>
<br>
Alastair Handley
 
Hi!<br>
<br>
See the &quot;environment variables&quot; thread.<br>
I posted a solution in August.<br>
<br>
Good luck. Bye, Otto.<br>
PS: Why do you need cgi? You could do it all with servlets (I think).<br>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top