INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Returning large binary to browswer via CGI

Returning large binary to browswer via CGI

(OP)
I have a fairly simple perl cgi script that generates a large ISO file (4GB). Perl is working fine from a CGI perspective because simple html generated by the perl cgi works fine. When executed at the shell, the perl script generates the large ISO file perfectly. However, when run via cgi, what is returned to the browser is a small 34k file.

I suspect either a timeout from apache, a size limitation, or both.

The html generated by perl is as follows:

Content-type: application/octet-stream;
Content-Disposition: attachment; filename="kickstart.iso"
Content-Transfer-Encoding: binary

The binary data follows immediately

I'm fairly green at HTML/CGI so any assistance might be appreciated.

RE: Returning large binary to browswer via CGI

Hi

Hard to say anything as you posted no CGI code so far.

Anyway, a generic advice : if not using the CGI module, try to set binmode.

Feherke.
http://feherke.github.com/

RE: Returning large binary to browswer via CGI

(OP)
Here's the perl code. Binmode is being used.

#!/usr/bin/perl

print "Content-type: application/octet-stream\n";
print "Content-Disposition: attachment\; filename=\"kickstart.iso\"\n";
print "Content-Transfer-Encoding: binary\n\n";

binmode(STDOUT);

exec("mkisofs -r -T -J -V \"Redhat KSBoot\" -b pub/isolinux/isolinux.bin -c pub/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -v .");

RE: Returning large binary to browswer via CGI

Hi

I was able to reproduce the problem.

But I am quite sure the problem is not with the transfer. If I redirect exec("mkisofs --all-that-stuff > /tmp/dolfantimmy.iso");, the resulted file will be also 34816 byte long.

As mkisofs's STDERR is not redirected, it gets written to the web server's error log file. There is a line :

Quote (error_log)

[Mon Oct 08 19:43:00 2012] [error] [client 192.168.2.81] mkisofs: Permission denied. Error opening boot image file 'pub/isolinux/isolinux.bin' for update.
If I set write permission on the pub/isolinux/ directory and the isolinux.bin file for the web server's user, the error message disappears and the downloaded file's size seems to be correct.

I have no experience with mkisofs, but I would give a try to the above.

Feherke.
http://feherke.github.com/

RE: Returning large binary to browswer via CGI

(OP)
Thanks so much for trying to help. Essentially the mkisofs is building a kickstart installation cd image.

I suspect you have a permissions issue on your side. The above perl script is called iso.pl If I execute the following....

perl ./iso.pl > foo.iso

a 4GB is generated as I would suspect.

RE: Returning large binary to browswer via CGI

Hi

Quote (dolfantimmy)

If I execute the following....

perl ./iso.pl > foo.iso

a 4GB is generated as I would suspect.
Also if you su - webserveruser first ? ( I mean, become to user with who's permissions the web server runs. Search the configuration files for User directive to find out the given user. )

Feherke.
http://feherke.github.com/

RE: Returning large binary to browswer via CGI

(OP)
I am running as root

RE: Returning large binary to browswer via CGI

Hi

Quote (dolfantimmy)

I am running as root
You mean, you have a User root directive in your web server configuration ? You read the warning before setting that, right ?

Quote (httpd documentation)

Security
Don't set User (or Group) to root unless you know exactly what you are doing, and what the dangers are.
( Apache HTTP Server Version 2.2 Documentation | Apache MPM Common Directives | User Directive )

Anyway, one thing you can still do : check your web server's logs.

Feherke.
http://feherke.github.com/

RE: Returning large binary to browswer via CGI

(OP)
Feherke,

I must have overlooked your suggestion regarding the write bit on isolinux directory isolinux.bin file. That solved the problem. Thanks a TON!!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close