From: Carlton T. <ca...@gi...> - 2006-08-23 17:40:33
|
Jamie, Thanks for the reply. I have implemented it but I am having a problem with the Perl modules. The problem seems to be caused by the fact that the program does not have all the context information correctly configured. As an example, the line: &foreign_require("useradmin", "user-lib.pl"); causes the program to generate the error message: "module useradmin does not exist" but if I replace that with: require 'useradmin/user-lib.pl'; it gets past that point OK. Also: &useradmin::making_changes(); causes the error: Undefined subroutine &useradmin::making_changes called... but removing the module name (ie. useradmin::), the call to making_changes works OK. By making changes to my program I can get Perl to satisfy all the direct references. However, those indirect references to Perl modules made by the Webmin functions I call are failing with similar error messages. Thanks in advance for any help you can provide. Regards ! -- Carlton ============================= GIFFORD INTERNET SERVICES Bristol, United Kingdom Tel: 0845 868 2245 Fax: 0845 004 6843 Email: ad...@gi... Web: http://www.gifford.co.uk ============================= On Tue, 22 Aug 2006, Jamie Cameron wrote: > On 22/Aug/2006 08:53 Carlton Thomas wrote .. > > > > Hi, > > > > I need to migrate some users from an old UNIX system to a > > Linux box. Since I need to do a number of operations, eg. > > copy user files, I have decided to write a Perl script to > > automate the task. To simplify things and to take advantage > > of some of Webmin's functionality, I would like to have my > > script call the Webmin "save_user.cgi" script to add the > > users to the Linux box. > > > > My script will run on the Linux box and do the following:- > > > > 1) read a line from the password file > > > > 2) parse the line to extract things like username, enc_password > > > > 3) call Webmin's "save_user.cgi" to add new user to linux box > > > > 4) rcp user's files from old box to new directories on Linux box > > > > 5) chown and chgrp user's files > > > > Is it feasible (or even possible) to use the Webmin module in this > > way? If it is possible, what do I need to do to ensure that the > > Webmin script will run correctly, eg. setting environment variables. > > Yes, you could use a command-line program that calls Webmin > functions to do this. I would recommend putting it in the base > directory (typically /usr/libexec/webmin), and coding it like : > > #!/usr/bin/perl > > $no_acl_check++; > $ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin"; > $ENV{'WEBMIN_VAR'} ||= "/var/webmin"; > if ($0 =~ /^(.*\/)[^\/]+$/) { > chdir($1); > } > chop($pwd = `pwd`); > $0 = "$pwd/create-users.pl"; > require './web-lib-lib.pl'; > $< == 0 || die "create-users.pl must be run as root"; > > &foreign_require("useradmin", "user-lib.pl"); > &useradmin::making_changes(); > while(<STDIN>) { > # Parse user and create object > $user = { ... }; > > &useradmin::create_user($user); > } > &useradmin::made_changes(); > > - Jamie > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > - > Forwarded by the Webmin mailing list at web...@li... > To remove yourself from this list, go to > http://lists.sourceforge.net/lists/listinfo/webadmin-list > |