Google Answers Logo
View Question
 
Q: perl script ( No Answer,   1 Comment )
Question  
Subject: perl script
Category: Computers > Programming
Asked by: myq-ga
List Price: $12.00
Posted: 18 Aug 2005 13:23 PDT
Expires: 17 Sep 2005 13:23 PDT
Question ID: 557395
on running a perl program (for the web), say A, I would like to call
another perl program, either prog B or prog C (depending on certain
conditions) , with certain arguments. If B and C are procedures within
A this is trivial, but what if B and C are totally different programs
written at different times for different reasons (maybe even not
resident on the same server and need to call a remote server) And I do
NOT want to simply forward to a URL
For example (a contrived example) let's say a visitor comes to my
signup form. Now dependent on whether the visitor checks , say,
computers or magazines, I would like control to pass to a totally
different script , say, script A if 'computers' is chosen and B if
'magazines' is chosen

Request for Question Clarification by palitoy-ga on 21 Aug 2005 11:27 PDT
Hi again myq-ga

I am a little unclear as to what you require but I think the solution
you need is to use the exec or system commands in Perl.

Take a look at these tutorials and let me know how you get on:
http://perldoc.perl.org/functions/exec.html
http://perldoc.perl.org/functions/system.html

Clarification of Question by myq-ga on 21 Aug 2005 22:41 PDT
have to take a closer look. will let you know if this works for my situation. thanks

Clarification of Question by myq-ga on 21 Aug 2005 22:49 PDT
let me  also clarify what I need:
say I have a script A. I call it from a web page. In certain cases the
script has to print something on the web. However, in certain other
conditions it should  output nothing to the web, simply call another
script B (can it be other than perl??) and let B do its thing.
A scenario easier to understand is where I already have scripts B and
C and would like B to be executed under some conditions and C under
others. I donb't want to 'integrate' these two because of difficulty
or copyright issues. I write a script A which branches to either B or
C WITH (important) the arguments, if any.
As I said I'll look into the links you mention but if there is
anything else you'd like to add, please do.
Answer  
There is no answer at this time.

Comments  
Subject: Re: perl script
From: zodiacman-ga on 22 Aug 2005 16:57 PDT
 
Hi there...
Not sure is this is robust enough for your needs, but here are several
ways I've called external programs from within the main perl program:

# PING THE IP ADDRESS PASSED AS ARG1; CAPTURE THE RESPONSE TO  ARRAY PINGDATA.
@pingdata = `ping $_[0]`;
In this example, which I yanked from a subroutine that PINGS a remote
IP address, the system PING command, the external program, is called
by enclosing it in the "tick mark" characters. The IP address was
passed to  the subroutine as Arg1, and the PING command executes when
the Subroutine executes this line. The results of the PING get stuffed
into the array @pingdata.

Example 2:     
$sendcmmd = `send "$sendmsg0" $NovellSr/$CaegAdm1 /B`;
This line calls the Novell system SEND command, passes a couple of 3
arguments. The message that is being sent is stored in the $SENDMSG0
variable; the name of the Novell login server is stored in $NovellSr, 
and the User login ID of the local system administrator is stored in
$CaegAdm1;  /B means use Bindery mode when the message gets sent.  The
whole command string is encoded in the "tick" marks so that it
executes like a command, and the results are store in $sendcmmd.

There are other ways I know, this is a simple way...

If you want to write a program that can go out across the network,
login  to a remote device, and actually interact with it, you should
check out the EXPECT program language. This langauge, which is used
within TCL scripts, lets you automate just about any process you would
normally do manually from a CMD, DOS, or CONSOLE window. They sell it
at www.activestate.com ...

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy