Solved

re: executing a script from another script

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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now