in reply to Configuration variables using run-time in put without -w complaints?

I am not sure why you are using eval. If I understand your issue, you want to get input from the user, set that to a few variables, and then use these variables as input to another program (in this case, adduser).

Why not try this:
print "Enter something:"; chomp($answer = <STDIN>); $transfer_log = "$log_dir/$answer"; $adduser = `/usr/sbin/adduser -g $group -G $user ...`;
Anyway, I truncated a bit of the data, but I think you get the idea. You want to read in whatever your interested in. In order to run a program (i.e., adduser), use backticks or system().
Hope that helps,
Shendal

Update: As KM pointed out in chat, you'll probably want to enable taint checking (-T). That will warn you on unsafe constructs where you may be running something you don't want to.
  • Comment on Re: Configuration variables using run-time in put without -w complaints?
  • Download Code

Replies are listed 'Best First'.
RE: Re: Configuration variables using run-time in put without -w complaints?
by TQuid (Sexton) on Jun 27, 2000 at 00:01 UTC
    Sorry, the eval is there as a result of recent thrashing, since I read that it is evaluated at run-time. The problem is that the snippet above is a separate config. file, read in with
    require '/etc/addvhost2rc';
    I've also tried using do {}, as suggested in the Cookbook, but the error messages persist regardless. It's important that it be a separate config file, as the script is intended to run on sites with varying directory layouts, adduser command syntax, etc.
      Oh, okay. Well, if you are doing a require to get the configuration in there, I'd suggest putting everything in the configuration file into a subroutine, then call it when you've done all the necessary set up.

      For example, your config file may look like this:
      # config file sub initConfig { $foo = "$user - bar"; # ... whatever... }
      Where your program file may look like this:
      # program require 'configuration_file'; print "Username:"; chomp($user = <STDIN>); # now $user exists, although you'd wanna check it for validity &initConfig(); # ... continue processing...
      Does that solve your problem? I've done it this way in the past, and it has worked out well.
      Hope that helps!