473,406 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Including results from one CGI in another.

Kelicula
176 Expert 100+
Is it possible to include the results from a cgi script in another cgi script?

Here is what I am trying to do.

cgi script 1, creates a web page dynamically depending on certain attributes of an external file.

I want my second cgi script to be able to "call" the first one, execute it and funnel the STDOUT into a namspace within the second file, to be included in that files STDOUT.

IE:
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -T
  2.  
  3. use strict;
  4. use warnings;
  5. use CGI;
  6.  
  7. $| =1;
  8.  
  9. print header;
  10.  
  11. my $thing = `results from output of other cgi script`;
  12.  
  13. my $q = new CGI;
  14. print $q->p('some stuff',
  15.                 "$thing");
  16.  
Anyone know if this can be done?
Oct 22 '07 #1
7 2222
eWish
971 Expert 512MB
With perl there is always more than one way to do most things. Here is one way you can achieve what you want.

script 1
Expand|Select|Wrap|Line Numbers
  1. #/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6.  
  7. sub some_routine{
  8.  
  9.    my $return_var = "Hello";
  10.    return($return_var);
  11.  
  12. }
  13.  
  14. 1;
script 2
Expand|Select|Wrap|Line Numbers
  1. #/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5.  
  6. require 'path/to/script2.pl';
  7.  
  8. my $thing = &some_routine();
  9.  
  10. print $thing;
  11.  
  12. 1;
Oct 22 '07 #2
Kelicula
176 Expert 100+
Excellent!! Thank you. It worked fine..
Oct 23 '07 #3
eWish
971 Expert 512MB
Excellent!! Thank you. It worked fine..
You are welcome! Glad to help.
Oct 24 '07 #4
KevinADC
4,059 Expert 2GB
"require" and "use" are very important functions to learn how to use with your perl programs. Especially if you want to write modular scripts or write modules that can be used in any script.
Oct 24 '07 #5
Kelicula
176 Expert 100+
"require" and "use" are very important functions to learn how to use with your perl programs. Especially if you want to write modular scripts or write modules that can be used in any script.
Yes, I am not able to write my own "module" yet. But I've been checking out some source code on other modules. It seems like a new language. Their are some terms that I'm not familiar with. "bless", "croak" etc...
So I can't really take advantage of "use" yet.

I am currently building a CMS so to speak with Template Toolkit.

I would very much appreciate any info (hint hint...a new "article") on creating modules...

once again,
Thanks to all!!
Oct 24 '07 #6
eWish
971 Expert 512MB
perldocs have a some nice tutorials on this. Also, Object-Oriented Perl from O'Reilly's

perlboot
perltoot
perltooc

There a several books you can buy to help. This is what I have done. Going broke too. :)
Oct 24 '07 #7
Kelicula
176 Expert 100+
perldocs have a some nice tutorials on this. Also, Object-Oriented Perl from O'Reilly's

perlboot
perltoot
perltooc

There a several books you can buy to help. This is what I have done. Going broke too. :)
I know what you mean! I got CGI programming, Template Toolkit, Programming the perl DBI, and Practical mod_perl from Oreilly the other day...

Haven't eaten dinner since!
Kust kidding, there is alot of good information in there.
I am looking forward to digesting it all.

Thanks.
Nov 15 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: George | last post by:
Hi, Anyone has the background for explaining? I have made a search on my name and I have got a link to another search engine. The link's title was the search phrase for the other search engine...
5
by: hntgzr | last post by:
I am trying to include a function in a .php file on a different server from the main .php files. I am using: include_path=http://www.anotherserver.com/foldername;...
4
by: Dica | last post by:
i apologize for what is no doubt a very rudimentary question, but i'm still trying to wrap my brain around .net coding habits. in classic asp, if i wanted to show search results, i'd just post the...
8
by: nrhayyal | last post by:
Hi c++ Gurus, Need your blessing. while testing few aspects with respect to header file inclusions, i observed few things which i would like to share with you. i have a file sqlca.h in which a...
8
by: Leszek | last post by:
Hi. Could you help solve the problem: i have a file that has two includes: //my script <?php include(.'/prog1.php'); include(.'/prog2.php'); ?>
9
by: Arancaytar | last post by:
I have so far seen two methods for including external resources as CSS stylesheets in a document. The first is this: <link href="/stylesheets/style.css" rel="stylesheet" type="text/css" /> And...
38
by: Neo Geshel | last post by:
I am seeking a method to load one JS file directly into another, *without* having to dynamically write <scripttags. Is there any method whereby I can call only one external JS file using a ...
20
by: Johan | last post by:
How can I include one XML file into another XML file (on the client side, in Firefox)? I think XInclude is just what I need, but Firefox doesn't support it:...
1
by: holmm | last post by:
Feel free to critise/comment. I've been slightly thrown in at the deep end! I'm building a query to count the number of test results that are unapproved, Out of spec, null etc per manufacturing...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.