Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

re: executing a script from another script

Posted on 1997-12-23
5
Medium Priority
?
225 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 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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…

715 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