Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

runrig (3385)

runrig
  dougwNO@SPAMcpan.org

Just another perl hacker somewhere near Disneyland

I have this homenode [perlmonks.org] of little consequence on Perl Monks [perlmonks.org] that you probably have no interest in whatsoever.

I also have some modules [cpan.org] on CPAN [cpan.org] some of which are marginally [cpan.org] more [cpan.org] useful [cpan.org] than others.

Journal of runrig (3385)

Thursday April 14, 2005
03:17 PM

Bizarre open bug

[ #24194 ]

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.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • It's not running under -T, is it? AFAIK, command line arguments are tainted.
    • 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!)

      • 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...