Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use warnings;
- use strict;
- use Bio::Graphics::Browser2;
- use Bio::Graphics::Browser2::Session;
- use Bio::Graphics::Browser2::UserDB;
- use Bio::Graphics::Browser2::Render;
- use Bio::Graphics::Browser2::UserTracks;
- use Data::Dumper;
- use CGI;
- use POSIX qw/setsid/;
- my $q = new CGI;
- my $upload_target = $q->param('upload');
- my $upload_name = $q->param('name');
- my $upload_type = $q->param('type');
- my $globals = Bio::Graphics::Browser2->open_globals;
- my $userdb = Bio::Graphics::Browser2::UserDB->new($globals);
- my $render = Bio::Graphics::Browser2::Render->new($globals);
- my $session = $render->session;
- my $data_source = $render->data_source;
- my $user_tracks = Bio::Graphics::Browser2::UserTracks->new($data_source,$session);
- my $pid = fork();
- if($pid == 0) {
- print STDERR "I'm the start of the parent: $pid\n";
- print $q->header;
- print $q->start_html( -title => 'Starting file upload',
- -style => ['http://fonts.googleapis.com/css?family=Lato','../../expression_ratios.css'],
- -script => {-type => 'JAVASCRIPT',
- -src => '../../expression_ratios.js'
- }
- );
- print $q->b("Upload Started!");
- print $q->end_html;
- print STDERR "I'm the end of the parent\n";
- } else {
- local $SIG{TERM} = sub {
- open FILE,">","/home/guest/data_dump2.txt" or die "Unable to open data_dump2.txt";
- print FILE "Cancelled by Apache timeout\n";
- close FILE;
- die "cancelled by Apache timeout";
- };
- open STDOUT, '>/dev/null' or die "Can't open /dev/null: $!";
- open STDIN, '</dev/null' or die "Can't open /dev/null: $!";
- print STDERR "I'm the child, I'm starting the upload: $pid\n";
- setsid or die "Can't start a new session: $!";
- print STDERR "upload_target: $upload_target\n";
- open my $fh, "<", $upload_target or die "unable to open upload target: $!";
- my @results = $user_tracks->upload_file($upload_name, $fh, $upload_type, 1);
- open FILE, ">", "/home/guest/data_dump.txt" or die "can't open file: $!";
- print FILE "Dump: ",Dumper(\@results);
- close FILE;
- print STDERR "Upload complete!\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement