in reply to 5.8.3 error not thrown by 5.8.0

samtregar has a point -- if you haven't posted line 407, there's not much we can do to help. On the other hand, if line 407 was actually this one (from the first snippet):
$error = system("$gzipLoc $dupeDir/$logFile");
Then the question might or might not have anything to do with the MORELOGS input, depending on how you assign values to $gzipLoc. If that string is not a problem, then the problem is that you are now getting lines of data from the file cited by $arcLogsUsToo -- is this file generated by some other Perl script (or by some other snippet in the current script)?

Given how you are handling the lines from MORELOGS, it's very plausible that you now have lines like:

Error message; no such file
Note the semi-colon. To work through this, here's the first thing to try:
# $error = system("$gzipLoc $dupeDir/$logFile"); # NOT THIS WAY $error = system($gzipLoc, "$dupeDir/$logFile"); # THIS WAY (update: +fixed spelling)
The "multi-argument" usage of system() is safer -- the sub-process named by the first variable is exec'ed, and its argument list is given to it as the list of subsequent args in the system call. When you pass system() a single scalar string, and if that string contains shell meta-characters (i.e. job control things like "|", "&", "<", ">" and of course semi-colon), it will launch a sub-shell, and pass the whole string as a command line. So if you have metacharacters in a variable that you believe is just a file name, and you put that into a single-string arg to system(), you're likely to be screwed.

Replies are listed 'Best First'.
Re: Re: 5.8.3 error not thrown by 5.8.0
by gennari (Novice) on Apr 01, 2004 at 16:45 UTC
    Cool! I've never used the "multi-argument" form of system(). I will definitely give that a go. Yes, line 407 is indeed:

    $error = system("$gzipLoc $dupeDir/$logFile");

    $gzipLoc = 'which gzip', which is not pretty, but I need to run on Solaris 2.6 and 9, and they put gzip in different places.

    So far, the print statements have shown me exactly what I thought I'd see (no problems), but I don't have one after every line yet, so I'm sure it's in there somewhere. :->

    Thank you for a very helpful piece of your mind and time.