I've got the most bizarre bug (first off, I'm stuck on perl v5.005_03 for this system). I'm passing in a file from the command line to a script:
my $file = shift || ''; open(FH, ">$file") or die "Error: $!";
If I call this from the command line, then all works as expected, but I don't want to call this from the command line, I want to use this as the pipe for a sql unloader utility. Part of the problem is that even if I have the wrong script name configured in the unloader, I don't get any errors, but I don't get an unload file either. And I don't get to see any errors from the script either. If I hardcode the file name in the script (assigning it to a variable), then it works okay. I've even gone wild with logging since I can't see errors. I've compared what's passed in with a variable with a hard coded string, and there is no difference (if ($file ne $str) { log_msg("Different!") }
).
I've come to the conclusion that I'm not allowed to pass in any command line arguments with this unload utility even though from all appearances the correct string is being passed in. It seems to die at the open, even when I don't say die, and no message is logged if I say 'open(...) or log_msg("Error"); log_msg("After open");', and no message is logged after the script tries to open the passed in string (but works ok if I open the hardcoded string).
So I've given up, I'm just going to write a template script (open(FH, ">%UNL_FILE%")...
) and preprocess that before running the unload (which I'm already doing with some config files that the unload utility needs). But I'm still baffled.
Taint? Yep!
runrig on 2005-04-14T22:37:26
Yep, because the command was being run under the SQL (un)loader utility, I was running into this (from the perlsec manpage):Perl automatically enables a set of special security checks, called taint mode, when it detects its program running with differing real and effective user or group IDs.(and thanks!)
Re:Taint? Yep!
runrig on 2005-04-15T15:46:43
And I've found I can see errors if I configure the pipe command to include">file.err 2>&1"
. I thought I had tried that, but maybe in my first try I didn't quote the entire command in the sql loader configuration file...or something...