in reply to Automating execution of shell scripts


From your description, it sounds like you have all the information you need in the first script to run the second script, so I'd suggest either wrapping things up into a single script *or* letting your first script write your second script.

For the first option, one common way to do it is to use perldoc -f fork to split your process so you can have your original process do the work you're currently doing in your first script, and then have the copied process do the work you'd do in the second script. There are also some packages on CPAN that help you manage multiple jobs that you may want to investigate.

I generally use the second option, though, which is to write your second script from your first. Since you already have a script that does the second task, all you really need to do is create a shell script to run the second task with the parameters you've created in the first task. Then once your first script runs, you can execute the new script that it creates, or even add some code to the end of your script to execute the script automatically.

#!env perl use strict; use warnings; open my $FH, '>', '' or die "Can't create script '': $!\n"; while (my $arg = shift) { print "Setting things up for task $arg\n"; # . . . do the work for the first script . . . # Create a new directory name my $the_dir = "dir_" . int(1000*rand); # build the directory and put the required file in it # Now that it's set up, write the command to run the # second script print $FH "/the/script/ '$the_dir' '$arg'\n"; }


When your only tool is a hammer, all problems look like your thumb.