in reply to Re: How to pass file paths in a master script which is used to run several perl scripts?
in thread How to pass file paths in a master script which is used to run several perl scripts?

Hi marto, Yes I Know that and that exactly is my doubt. I've defined $cmd1 in my Master script as u can see above in my code and I am trying to run my gui_calci script through master script. If I have 50 Scripts I need to run through a master script and each of those scripts contain a filepath, I want to pass all those file paths from master script or someway or another from outside because it is very difficuilt to modify filepaths in 50 scripts everytime . Any suggestions would help? P.S. Apologies for not posting the error message

  • Comment on Re^2: How to pass file paths in a master script which is used to run several perl scripts?

Replies are listed 'Best First'.
Re^3: How to pass file paths in a master script which is used to run several perl scripts?
by marto (Cardinal) on Oct 18, 2016 at 10:01 UTC

    It doesn't work this way. In the master script you define your variables, however you run another perl script via system. It knows nothing about the variables in the master script. Consider the following example: master.pl

    #!/usr/bin/perl use strict; use warnings; my $secret = 'BruceWayneisBatman'; my @cmd = ('perl', 'child.pl', $secret); system(@cmd) == 0 or die "system @cmd failed: $?";

    child.pl

    #!/usr/bin/perl use strict; use warnings; my $message = $ARGV[0]; print "The master script passed: $message\n";

    Again see system.

      Nothing technically wrong with this, just a remark/reminder.

      Passing a secret via the command line exposes the secret in the process list. Everybody with access to 'ps' or /proc/<pid>/cmdline can see the secret. (This may include some totally unrelated piece of software which logs the contents of 'ps -ef' for debugging/troubleshooting purposes.)

      Yes, this is kinda obvious, but I wanted to put attention to it anyway.

        $secret was a light hearted variable name, it should have just been $message. Obviously Bruce Wayne isn't Batman, how could he possibly keep up crime fighting at night while tending to the affairs of the Wayne foundation? (a Simpsons reference if you're unaware ;). Your point is valid however. See further down the thread were 20 or so paths are supposed to be getting passed to 50 different child scripts, and the suggestion using config files rather than passing anything in this manner.