SOLVED
This is terribly annoying me. I'm only a perl apprentice, so don't expect too much ;-)
My Question now is: How do I call an external program with the system() func from a CGI-Script?
I am uploading an MS Excel file and want it to be parsed by an external program which will insert it into a database quietly. The shell call for this would be:
ccupdate_db -ExcelFile /var/www/cgi-bin/upload/test.xls -q
here's the code (with debug stuff):
# Variables alsway hold the full path to the file mentioned
my $ccupdate_db = "/var/www/cgi-bin/ccupdate_db";
my $excel_file = "$uploadedfile"; #i.e. "/var/www/cgi-bin/upload/test.
+xls"
my @args = ($ccupdate_db, "-ExcelFile $excel_file", "-q");
my $exit_code = system(@args);
print "Exit Code: ".$exit_code/256."<br>";
print "Error: ".$!:"<br>";
print "ARGS: ";
foreach my $val (@args)
{
print $val." ";
}
This will output:
Exit Code: 2
Error: Bad file descriptor
Args: /var/www/cgi-bin/ccupdate_db -ExcelFile /var/www/cgi-bin/upload/test.xls -q
WHY???
If I copy the outputted lines to the shell, all works fine...
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.