Re: Output redirection
by ikegami (Patriarch) on Jun 12, 2009 at 20:37 UTC
|
I don't get it. What's stopping you from changing the location?
I can't use any CPAN modules because there's no guarantee that any such module will exist on the machine that will run the scripts.
That's not true. Whatever installs your script on the machines can also place the necessary modules.
| [reply] |
Re: Output redirection
by Perlbotics (Archbishop) on Jun 12, 2009 at 21:25 UTC
|
Hi, if I understand your problem correct you want to change the default output location of scripts A,B,C,D to another directory,
probably C:\Results and you want control that location from another script that coordinates all those script calls.
Furthermore, you want to redirect STDERR from each script into one or more logfiles.
Seems, that you first need to check if scriptA-D allow to change their respective output-directories.
If they don't support appropriate command line switches or environment variables, you might need to patch those scripts
(they are all Perl - guessing that from the *.pl suffix, so you can edit them or create patched copies).
You could use Getopt::Long to provide a new output directory via command line to scripts A,B,C,D.
Then do something along system("...pathtoscript/scriptA.pl --dest-dir=$my_common_dest_dir 2>$my_common_log_fileA.log").
Check result of system. If you are already going to patch those scripts, you could also redirect STDERR from within these scripts (create i.e. a --log-stderr switch).
If these scripts output into a directory relative to where they were called, chdir and File::chdir might be something to investigate.
HTH (take this advice with a grain of salt/sugar/whatever since I do not use Perl under Windows that much...)
| [reply] [d/l] |
Re: Output redirection
by markkawika (Monk) on Jun 12, 2009 at 21:18 UTC
|
It sounds to me like the scripts you're calling, scriptA.pl and scriptB.pl are creating output files to specific directories they are choosing.
If a single invocation of a script is creating thousands of files, then it is not using STDOUT for its output; it's creating files. You cannot do anything to change that short of modifying those scripts.
It sounds to me like your only choice is going to be to move those files after they've been created to the location you want them to end up. | [reply] [d/l] [select] |
|
|
Maybe possible with chdir or chroot
| [reply] |
|
|
Or making scriptA and scriptB links to the desired output dir.
| [reply] |
|
|
|
|
|
|
|
| [reply] |
Re: Output redirection
by Khen1950fx (Canon) on Jun 12, 2009 at 21:03 UTC
|
| [reply] |
Re: Output redirection
by graff (Chancellor) on Jun 13, 2009 at 16:56 UTC
|
If you have barriers to modifying scripts ABCD to control where they save their outputs, why not just let them do what they do, and use FIle::Copy (a core module, included with every perl installation) to move() all those data files wherever you want them to be?
(I'm assuming that if there's any danger of file name collisions, you'll be watching out for that, and renaming files as needed when pooling them together into one place -- that might be another reason to take this particular approach.) | [reply] [d/l] |
Re: Output redirection
by Anonymous Monk on Jun 15, 2009 at 13:00 UTC
|
Thanks for your input. I know about the copy() function, but was wondering if there was an easier, more efficient way to redirect the files. I might end up requesting permission to patch the called programs to make them output to STDOUT, or to accept arguments that change their default output directories. | [reply] |