![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Calling a C-function froma Perl script | jisha | Shell Programming and Scripting | 9 | 05-07-2008 09:59 PM |
| Calling Winzip from perl script | MobileUser | Shell Programming and Scripting | 5 | 04-04-2007 12:51 AM |
| calling a shell script from perl | gurukottur | Shell Programming and Scripting | 3 | 10-05-2006 08:48 AM |
| Box A's perl script calling box B's shell script | new2ss | Shell Programming and Scripting | 1 | 09-13-2006 03:17 AM |
| Calling CGI Perl in Shell script [urgent] | DeepakXavier | Shell Programming and Scripting | 0 | 10-08-2005 10:51 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
Calling a perl script from a perl script
Code:
printf(”Going to call another script... \n”); system(”/my_dir/B.pl”); # call another perl script B.pl exit; I have two concerns : 1) This there a better way of achieving the same purpose ( ie call another perl script from a perl script)? 2) Notice there is an exit command in my calling script. Will the exit command be executed only after B.pl is completed OR it will be executed immediately B.pl is called? |
| Forum Sponsor | ||
|
|
|
|||
|
Quote:
Quote:
Did you try to find out whether that is the case? |
|
|||
|
Quote:
i qoute from perldoc for system "...Does exactly the same thing as exec LIST , except that a fork is done first, and the parent process waits for the child process to complete...." So i can take it that my first script will wait for B.pl to finish before exiting. the perldoc entry for exec says " ..The exec function executes a system command and never returns--". Therefore i can assume that after it calls B.pl, the calling script will exit. My intention is not to wait for B.pl to finish, ( ie, runs B.pl and the caller script itself exit ) therefore i should use exec? Any draw backs? |
|
|||
|
I like to require any other files at the beginning of the main script then just call the routines in them as needed. This may or may not be the best way, but it works pretty well for me. By the way, if I remember correctly, I believe the file you're calling does not necessarily need the standard perl script header, does not have to end in "pl" or "cgi", and does not need executable permissions.
(main_file.pl) #!/usr/bin/perl require "other_file.pl"; &do_something; &do_something_else; exit; (other_file.pl) sub do_something{ print "Content-type: text/html\n\n"; print "ok"; } sub do_something_else{ print "Content-type: text/html\n\n"; print "ok again"; } 1; # return true I didn't test that script, but I know it's real close to what I do. |
|||
| Google The UNIX and Linux Forums |