develooper Front page | perl.beginners | Postings from February 2009

Forked script doesnt exec from a cgi script

Thread Next
From:
Neetee Pawa
Date:
February 8, 2009 00:47
Subject:
Forked script doesnt exec from a cgi script
Message ID:
OF960014E3.3BFF3042-ON65257557.002FDBD7-65257557.00304AEE@csc.com
Hi All,

I am trying to invoke a perl script in background  from a cgi script. Code 
seems working as i can see the script gets invoked however nothing gets 
executed from the script. ( the script is functioning fine from the 
command prompt)

Here is what i have written

$SIG{CHLD}='IGNORE';
my $pid=fork();

#Starting child
if($pid) {
        $layout->addContent("<br /><p>" . "Script is running(PID: $pid). 
Should be done soon.". "</p>");
              if (defined($layout)) {
               $layout->output();
        }
        exit(0);
       }else{
                   #  close(STDOUT);
                     close(STDERR);
                     close(STDIN);
       exec "/opt/soe/local/bin/perl /opt/soe/local/bin/test.pl "; # Run 
script in background
       #exec "/opt/soe/local/bin/perl /opt/soe/local/bin/pres-upd-reports 
--report=basic-monthly-report-cpu --account=CSC "; # Run script in 
background
        }

}


I tried to try a test.pl which sleeps for 10 secs , then i can see it 
running in ps -ef output but i asked it to touch a file in /tmp and it 
wasnt able to touch the file.

Any clue?? Please help.

Thanks

Neetee


CSC • This is a PRIVATE message. If you are not the intended recipient, 
please delete without copying and kindly advise us by e-mail of the 
mistake in delivery.  NOTE: Regardless of content, this e-mail shall not 
operate to bind CSC to any order or other contract unless pursuant to 
explicit written agreement or government initiative expressly permitting 
the use of e-mail for such purpose • Computer Sciences Corporation India 
Pvt Ltd • 7th,Floor, Block 1B, DLF IT Park, Sivaji Garden, Moonlight Stop, 
Nandambakkam Post, Ramapuram, Chennai-600 089.


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About