in reply to Re: conditional calling of script from other script
in thread conditional calling of script from other script

1. i want my script1.pl to be executed any number of times. by executing the command # perl $PATH/script1.pl -qx . when this is executed for first time i will then execute script2.pl .now when i execute my script script1.pl second time or more number of times from same command as above. 2. i have to use some external factor to see if the script2.pl needs to be executed but i am unable to decide and that the main i am asking you all. i think this may give you some good idea of what i am asking.
  • Comment on Re^2: conditional calling of script from other script

Replies are listed 'Best First'.
Re^3: conditional calling of script from other script
by bgreenlee (Friar) on Feb 04, 2005 at 06:32 UTC

    First of all, to answer your question directly, just have script1 check for the existence of a particular file; if that file doesn't exist, create it and run script2:

    my $LOCKFILE = 'script1.lock'; if (!-e $LOCKFILE) { open FH, ">$LOCKFILE" or die $!; close FH; system("perl script2.pl"); }

    However, if they're both perl scripts, it seems silly to do a fork and invoke another perl interpreter to run it. Can't you just use or require it and call whatever function(s) you need directly?

    -b

Re^3: conditional calling of script from other script
by jpk236 (Monk) on Feb 04, 2005 at 05:57 UTC
    sachin,

    Can you provide us with some code as to what these two scripts do? Thanks.

    Justin