There are two issues here:
> Basically,
> you use the "$u" hash to add a new [_meta]
> variable. Or better yet, you use it to create an entire new
> section (call it [_local] or [_site] or something) and put
> your variables in there.
1). I did figure out how to add a question using the $u hash and I created
a new section - [_oe]. However, the section was printed at the top of the
unattend file (before comments or anything else). I don't like it there. I
want it at the bottom, underneath [_meta]. Is there anyway to fix that?
>
> Can you give an example of something you are trying to do?
>
2). Yes, I can give you an example of something I am trying to do. Earlier,
I posted to the list about how I modified install.pl to display a
multi-choice dialog that lets you choose printers to setup. I would like to
separate all of that code from install.pl so I can easily upgrade without
having to rework install.pl every time a new version is released. Here are
the changes that I made to install.pl and the associated scripts needed to
make the patch run. Perhaps you could look them over and tell me how to
make my dialog independent of install.pl?
###########################
Changes made to Install.pl
###########################
Added the following lines to "sub create_postinst_bat ()". The code is
placed right after the section "# NTP servers"
----------------------------------------------------------------------------
----------------------------------------------------------------------------
---------------
# Printers
if (-e "c:/netinst/printset.vbs") {
push @postinst_lines, "call c:\\netinst\\printset.vbs";
}
Added the following lines after "# Create C:\netinst and subdirectories."
and before "# Create unattend.txt file."
----------------------------------------------------------------------------
----------------------------------------------------------------------------
--------
# Call site-specific printer setup dialog.
my $print_conf = 'z:\\site\\printers.pl';
if (-e $print_conf) {
my $pr_result = do $print_conf;
$@
and die "do $print_conf failed: $@";
defined $pr_result
or die "Could not do $print_conf: $^E";
}
Added the following lines so that a new option would be pushed into
@edit_choices. The code was placed after the push of "$doit" into
@edit_choices.
----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------
my $printsetup = $u->{'_meta'}->{'printsetup'};
defined $printsetup
and push (@edit_choices,
"Edit $printsetup (will be run by $postinst)"
=> $printsetup);
###########################
Contents of printers.pl
###########################
sub create_print_setup () {
my $netinst = 'c:\\netinst';
my @print_lines;
my $print_string = $u->{'_meta'}->{'printers'};
my @printers = split /;/, $print_string if ($print_string);
if (scalar @printers > 0) {
push @print_lines,
'Set WshNetwork = CreateObject("WScript.Network")';
foreach (@printers) {
push @print_lines, "WshNetwork.AddWindowsPrinterConnection \"$_\"";
}
}
if (scalar @print_lines > 0) {
open (OUT, ">$netinst\\printset.vbs");
print "Creating $netinst\\printset.vbs...";
foreach (@print_lines) {
print OUT "$_\n"
}
print "done.\n\n";
}
return 'c:\netinst\printset.vbs';
}
$u->comments ('_meta', 'printers') =
['Printers to be installed'];
$u->{'_meta'}->{'printers'} =
sub {
my $printers = "z:/site/printers.txt";
my @print_array;
if (-e $printers) {
open (IN, "$printers") || warn "Could not open file: $!";
while (<IN>) {
chomp;
push @print_array, $_;
}
close (IN);
@selected_printers = multi_choice ('Choose printers to setup.',
@print_array);
return join ';', @selected_printers;
}
};
$u->{'_meta'}->{'printsetup'} = \&create_print_setup;
############################
Sample contents of printers.txt
############################
\\my_print_server\printer1
\\my_print_server\printer2
\\my_print_server\printer3
#######################
Notes
#######################
printers.pl and printers.txt both go in "install\site"
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
unattended-info mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/unattended-info