OU812 has asked for the wisdom of the Perl Monks concerning the following question:

I'd like to use a perl script to apply a the contents of text data to a windows executible.
In this particular case, a Answer File to a 'Acrobat Reader' installer.

Here's an ugly way of doing it with the script below:
This outputs a answerfile to the computers hardrive and THEN applies it to the executible
It's the only thing that works...
open(ACROBAT, ">c:\\acrobat5.iss" ) || die "acrobat5.iss: $!\n"; format ACROBAT= [InstallShield Silent] Version=v5.00.000 File=Response File [File Transfer] OverwriteReadOnly=NoToAll [DlgOrder] Dlg0=SdWelcome-0 Count=3 Dlg1=SdAskDestPath-0 Dlg2=MessageBox-0 [SdWelcome-0] Result=1 [SdAskDestPath-0] szDir=C:\Program Files\Adobe\Acrobat 5.0 Result=1 [Application] Name=Reader Version=5.0 Company=Adobe Lang=0009 [MessageBox-0] Result=1 . write ACROBAT; my $pkg = '\\acrobat5.exe /a /s /sms /f1_$'; system $pkg; close ACROBAT; unlink ("c:\\acrobat5.iss");

It would be nice not to author a seperate file, as above but the way windows executables apply text files confuses me.

Windows executibles that get instructions from whole text files, such as answerfiles and AutoIt scripts, seem to require those files have a actual location. Parsing them from __DATA__ dosn't work, as in this unssucsful example below (just starts a new instance of acrobat5.exe for each line each line of DATA)
while( <DATA> ){ my $pkg = "c:\\acrobat5.exe /a /s /sms /f1$_"; system $pkg; } __DATA__ [InstallShield Silent] Version=v5.00.000 File=Response File [File Transfer] OverwriteReadOnly=NoToAll [DlgOrder] Dlg0=SdWelcome-0 Count=3 Dlg1=SdAskDestPath-0 Dlg2=MessageBox-0 [SdWelcome-0] Result=1 [SdAskDestPath-0] szDir=C:\Program Files\Adobe\Acrobat 5.0 Result=1 [Application] Name=Reader Version=5.0 Company=Adobe Lang=0009 [MessageBox-0] Result=1

I attempted this without luck too... It was supposed to feed all the data at once, but it didn't work either;
my $answer_file = (' [InstallShield Silent] Version=v5.00.000 File=Response File [File Transfer] OverwriteReadOnly=NoToAll [DlgOrder] Dlg0=SdWelcome-0 Count=3 Dlg1=SdAskDestPath-0 Dlg2=MessageBox-0 [SdWelcome-0] Result=1 [SdAskDestPath-0] szDir=C:\Program Files\Adobe\Acrobat 5.0 Result=1 [Application] Name=Reader Version=5.0 Company=Adobe Lang=0009 [MessageBox-0] Result=1'); my $pkg = "c:\\acrobat5.exe /a /s /sms /f1$answer_file"; system $pkg;

Ideas? It's seems it's all about tricking the installer to think the data is a file on the harddrive.
Yes, it would be easy just to keep a seperate answer file, but I'm trying to avoid the overhead and keep things compact.

Replies are listed 'Best First'.
Re: Apply answer files to windows executibles
by PodMaster (Abbot) on Feb 25, 2004 at 10:22 UTC
    Ideas? It's seems it's all about tricking the installer to think the data is a file on the harddrive.
    Which would have nothing to do with perl. There's no point in trying to trick the installer.
    use File::Temp 'tempfile'; my ($fh, $filename) = tempfile( UNLINK => 1, OPEN => 1 ); print {$fh} <DATA>; close $fh; system @yada, "/fl", $filename; __DATA__ yada

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Apply answer files to windows executibles
by Mr. Muskrat (Canon) on Feb 25, 2004 at 13:34 UTC

    Yes, it would be easy just to keep a seperate answer file, but I'm trying to avoid the overhead and keep things compact.

    And how does putting the answer file in a script makes it any more compact? The script is nothing more than a wrapper around the answer file; that means it adds more lines increasing the "overhead" so to speak.

Re: Apply answer files to windows executibles
by rchiav (Deacon) on Feb 25, 2004 at 14:13 UTC
    I think this is a case of trying to manage things to much. There is no overhead by creating another text file. Whether you create a seperate file or put it in another, it's still the same amount of bytes. You've actually added the overhead of processing the text and essentially generating another file. You're also adding another layer of complexity. If you want things more compact and have less overhead, you can get rid of the use of perl alltogether.