Solved

re: executing a script from another script

Posted on 1997-12-23
5
222 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
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 how to count occurrences of each item in an array.

738 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