Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

re: executing a script from another script

Posted on 1997-12-23
5
Medium Priority
?
227 Views
Last Modified: 2013-12-25
there's a script that takes information from a form via the "GET" method to a gawk script that searches a database returning results matching the inputed criteria.  is there a way i can call this program passing it the search criteria from another script written in perl and getting the desired results for processing in the perl script?
0
Comment
Question by:PuterPan
  • 2
  • 2
5 Comments
 
LVL 85

Expert Comment

by:ozo
ID: 1831732
Yes, you can use any of
open
qx
system
open2
pipe/fork/exec
to do it.
0
 
LVL 1

Accepted Solution

by:
nanullnet earned 300 total points
ID: 1831733
#!/usr/local/bin/perl -w
$stuff = $ENV{'QUERY_STRING'};
$output = system "/path_to_script/script $stuff";

You may need to use an option for command line info like "-i" but I would check the gawk docs to be sure.
0
 
LVL 85

Expert Comment

by:ozo
ID: 1831734
If you want to get output from the command, and not just the exit value,
that would be either

 $output = system "/path_to_script/script $stuff > file";
 open(FILE,"<file") or die "can't read file: $!";
 while( <FILE> ){
   proces_result($_);
 }
 close FILE;

or

 $output = `/path_to_script/script $stuff`;
 proces_result($output);

or

 open(OUTPUT,"/path_to_script/script $stuff|");
 while( <OUTPUT> ){
   proces_result($_);
 }

(assuming your gawk script takes its search criteria from the command line,
in QUERY_STRING format.  If it takes its input a different way,
or in a different format, you'll have to change the call appropriately)
0
 
LVL 1

Expert Comment

by:nanullnet
ID: 1831735
I agree ozo.  I forgot that the system command returns an exit value instead of output.  Use the backticks instead `.

$output = `/path_to_script/script $stuff`;

That'll work better.
0
 

Author Comment

by:PuterPan
ID: 1831736
these answers totally didn't work.  maybe i didn't state the question well enough.

i need the results of the search script written in gawk to be placed into another script for processing.  i have to send the search criteria from the perl script to the gawk script.  however, the gawk script expects the search criteria to come from a form on a web page.  someone in a newsgroup said that the perl script has to "act" like the web page.  how?  should i send it a bunch of headers?  there has to be a way to get this info out.  if necessary, i will modify the gawk script.  but how can i set it up to receive the query string from another script?  i should also mention, that i'm working remotely, i don't have access to the command line.  so far, no one anywhere has been able to answer this question.  if it isn't possible, please let me know so i can move on.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

877 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question