Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Calling mkisofs from perl cgi

by finfan (Acolyte)
on Oct 05, 2012 at 14:29 UTC ( #997486=perlquestion: print w/ replies, xml ) Need Help??
finfan has asked for the wisdom of the Perl Monks concerning the following question:

I am creating an automated kickstart process. The html and perl code to build the ks.cfg are working perfectly. I can build my kickstart iso with no problems using

mkisofs -r -T -J -V "Redhat KSBoot" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -v -o /var/www/html/linuxboot.iso .

I am trying to have apache return the iso via http as follows:
#!/usr/bin/perl print "Content-type: application/octet-stream\n"; print "Content-Disposition: attachment\; filename=\"kickstart.iso\"\n" +; print "Content-Transfer-Encoding: binary\n"; binmode(STDOUT); exec("mkisofs -r -T -J -V \"Redhat KSBoot\" -b pub/isolinux/isolinux.b +in -c pub/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-in +fo-table -v .");
I do get a file sent to the browser, but it's only 35k. It consists of roughly 100 blank lines, and then the isogen headers. It should be roughly 4GB, and that header should be the first thing in the file. I'm pulling what little hair I have left out trying to figure this one out. Any help appreciated.

Comment on Calling mkisofs from perl cgi
Download Code
Re: Calling mkisofs from perl cgi
by choroba (Abbot) on Oct 05, 2012 at 14:34 UTC
    Where is the empty line between the header and the body?
    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
      No, the file starts with a bunch of blank lines. Then I see what appears to be the header of the iso, and then the file ends.
        I meant the empty line after the HTTP header.
        لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Calling mkisofs from perl cgi
by tobyink (Abbot) on Oct 05, 2012 at 15:12 UTC

    What happens when you run your CGI script from the command line?

    perl your-script.cgi > tmp.iso

    Do you get the 4 GB ISO file then (albeit with a little HTTP crud at the start of the file)? Or do you still only get 35 KB?

    Also, have you tried using a full, absolute path to the directory you want an image for, rather than just "."?

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      Still the 35KB file. I have tried to use absolute paths, but it always fails. Never have seen that before. But relative path works fine running mkisofs from the shell.
      Sorry, missed the first question. executed from command line, it generates the iso perfectly.

        If the CGI script runs OK at the command line then it's unlikely to be a Perl-specific problem. It's possible that Apache is putting an output size or time limit on your script.

        perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://997486]
Approved by marto
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2014-08-30 16:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls