Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

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/ -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/ -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.

Replies are listed 'Best First'.
Re: Calling mkisofs from perl cgi
by choroba (Chancellor) 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://997486]
Approved by marto
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2017-03-28 03:28 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (326 votes). Check out past polls.