Solved

re: executing a script from another script

Posted on 1997-12-23
5
217 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 84

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 100 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 84

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

791 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