Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

(8)Exec format error: when running the script on Linux

by ikkon (Monk)
on Jan 19, 2007 at 18:08 UTC ( #595516=perlquestion: print w/ replies, xml ) Need Help??
ikkon has asked for the wisdom of the Perl Monks concerning the following question:

on my windows machine this runs just fine, but when i load it to the server it fails and the only error I get is the execution error. I not sure what causeing it, I tried the dos2unix command with no avail, any Ideas?

#!/usr/bin/perl -wT use PDF::API2; use PDF::Table; use perlchartdir; use CGI; use strict; use warnings; print header( "application/pdf" ); use constant mm => 25.4/72; use constant in => 1/72; use constant pt => 1; sub setImage; sub newText; sub newTextRight; sub checkCurrency; sub GrabParams; my $q = new CGI; my %valueHash; GrabParams(); my $ID = $q->param("ID"); ###################################################### ## Config Variable Edit this for Easy Configuration ## ###################################################### my $Template = qq(Dell_Deployment_Optimization_Report.pdf); my $ChartImageName = "DellDOChart".$ID.".jpeg"; my $bubbleName = "Bubble".$ID.".jpeg"; ## Text Vars my $fontType = qq(Helvetica); my $CurrencySymbol = $q->param("CurrencySymbol"); ############### MAKE stack bar CHART #################### # The data for the bar chart my $data6 = [$valueHash{"ch1v11"}, $valueHash{"ch1v21"}, $valueHash{"c +h1v31"}, $valueHash{"ch1v41"}]; my $data5 = [$valueHash{"ch1v12"}, $valueHash{"ch1v22"}, $valueHash{"c +h1v32"}, $valueHash{"ch1v42"}]; my $data4 = [$valueHash{"ch1v13"}, $valueHash{"ch1v23"}, $valueHash{"c +h1v33"}, $valueHash{"ch1v43"}]; my $data3 = [$valueHash{"ch1v14"}, $valueHash{"ch1v24"}, $valueHash{"c +h1v34"}, $valueHash{"ch1v44"}]; my $data2 = [$valueHash{"ch1v15"}, $valueHash{"ch1v25"}, $valueHash{"c +h1v35"}, $valueHash{"ch1v45"}]; my $data1 = [$valueHash{"ch1v16"}, $valueHash{"ch1v26"}, $valueHash{"c +h1v36"}, $valueHash{"ch1v46"}]; my $data0 = [$valueHash{"ch1v17"}, $valueHash{"ch1v27"}, $valueHash{"c +h1v37"}, $valueHash{"ch1v47"}]; # The labels for the bar chart my $labels = [$valueHash{"ch1x1"}, $valueHash{"ch1x2"}, $valueHash{"ch +1x3"}, $valueHash{"ch1x4"}]; # Create a XYChart object of size 500 x 320 pixels my $c = new XYChart(540, 450); # Set the plotarea at (100, 40) and of size 280 x 240 pixels $c->setPlotArea(105, 45, 305, 375); # Add a legend box at (400, 100) $c->addLegend(349, 42)->setBackground(0xffffff); #$c->LegendBox # Add a title to the chart using 14 points Times Bold Itatic font $c->addTitle($valueHash{"ch1title"}, "", 13); # Add a title to the y axis. Draw the title upright (font angle = 0) #$c->yAxis()->setTitle($q->param("Currency"))->setFontAngle(90); # Set the labels on the x axis $c->yAxis()->setLabelFormat("$CurrencySymbol"." "."{value|,}"); # Set the labels on the x axis $c->xAxis()->setLabels($labels); # Add a stacked bar layer and set the layer 3D depth to 8 pixels my $layer = $c->addBarLayer2($perlchartdir::Stack, 8); # Add the seven data sets to the bar layer $layer->addDataSet($data6, 0x9999ff, $valueHash{"ch1s1"}); $layer->addDataSet($data5, 0x993366, $valueHash{"ch1s2"}); $layer->addDataSet($data4, 0xffffcc, $valueHash{"ch1s3"}); $layer->addDataSet($data3, 0xccffff, $valueHash{"ch1s4"}); $layer->addDataSet($data2, 0x660066, $valueHash{"ch1s5"}); $layer->addDataSet($data1, 0xff8080, $valueHash{"ch1s6"}); $layer->addDataSet($data0, 0x0066cc, $valueHash{"ch1s7"}); # Enable bar label for the whole bar #$layer->setAggregateLabelStyle(); # Enable bar label for each segment of the stacked bar #$layer->setDataLabelStyle(); # output the chart $c->makeChart($ChartImageName); ######################### END CHART ############################# ########################### BUBBLE CHART ############################# +################ # The XYZ points for the bubble chart my $dataX0 = [150, 300, 1000, 1700]; my $dataY0 = [12, 60, 25, 65]; my $dataZ0 = [20, 50, 50, 85]; my $dataX1 = [500, 1000, 1300]; my $dataY1 = [35, 50, 75]; my $dataZ1 = [30, 55, 95]; # Create a XYChart object of size 450 x 420 pixels my $ch = new XYChart(450, 420); # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a li +ght grey border # (0xc0c0c0). Turn on both horizontal and vertical grid lines with lig +ht grey color # (0xc0c0c0) $ch->setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1); # Add a legend box at (50, 30) (top of the chart) with horizontal layo +ut. Use 12 pts # Times Bold Italic font. Set the background and border color to Trans +parent. $ch->addLegend(50, 30, 0, "timesbi.ttf", 12)->setBackground($perlchart +dir::Transparent ); # Add a title to the chart using 18 pts Times Bold Itatic font. $ch->addTitle("Product Comparison Chart", "timesbi.ttf", 18); # Add a title to the y axis using 12 pts Arial Bold Italic font $ch->yAxis()->setTitle("Capacity (tons)", "arialbi.ttf", 12); # Add a title to the x axis using 12 pts Arial Bold Italic font $ch->xAxis()->setTitle("Range (miles)", "arialbi.ttf", 12); # Set the axes line width to 3 pixels $ch->xAxis()->setWidth(3); $ch->yAxis()->setWidth(3); # Add (dataX0, dataY0) as a scatter layer with semi-transparent red (0 +x80ff3333) # circle symbols, where the circle size is modulated by dataZ0. This c +reates a bubble # effect. $ch->addScatterLayer($dataX0, $dataY0, "Technology AAA", $perlchartdir +::CircleSymbol, 9, 0x80ff3333, 0x80ff3333)->setSymbolScale($dataZ0); # Add (dataX1, dataY1) as a scatter layer with semi-transparent green +(0x803333ff) # circle symbols, where the circle size is modulated by dataZ1. This c +reates a bubble # effect. $ch->addScatterLayer($dataX1, $dataY1, "Technology BBB", $perlchartdir +::CircleSymbol, 9, 0x803333ff, 0x803333ff)->setSymbolScale($dataZ1); # output the chart $ch->makeChart($bubbleName); ########################### MAKE PDF ############################ my $pdftable = new PDF::Table; my $pdf = PDF::API2->open($Template); my $page = $pdf->openpage(1); ##### Set Font ############### my %font = ( Helvetica => { Bold => $pdf->corefont('Helvetica-Bold', -encoding => +'latin1'), Roman => $pdf->corefont('Helvetica', -encoding => ' +latin1'), Italic => $pdf->corefont('Helvetica-Oblique', -encoding => +'latin1'), }, ); ## Set Image( x, y, w, h) ############### setImage($ChartImageName, 115/mm, 171/mm, 89/mm, 75/mm); ## Set Text ############### #Title newText($fontType, 'Roman', 12.5/pt, 'black', 13.5/mm, 263/mm, $value +Hash{"repTitle"}); #ES newText($fontType, 'Roman', 7/pt, 'black', 12.5/mm, 254/mm, $valueHas +h{"ES1"}); newText($fontType, 'Roman', 7/pt, 'black', 12.5/mm, 251/mm, $valueHas +h{"ES2"}); newText($fontType, 'Roman', 7/pt, 'black', 12.5/mm, 248/mm, $valueHas +h{"ES3"}); newText($fontType, 'Roman', 7/pt, 'black', 12.5/mm, 245/mm, $valueHas +h{"ES4"}); #Assumptions newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 230/mm, $valueHas +h{"CompanyType"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 226/mm, $valueHas +h{"Country"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 222/mm, $valueHas +h{"Currency"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 215/mm, $valueHas +h{"D9"}); #newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 196/mm, $valueHa +sh{"D11"}); #newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 192/mm, $valueHa +sh{"D12"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 211/mm, $valueHas +h{"D14"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 207/mm, $valueHas +h{"D15"}); #Current Optimization Practices newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 195/mm, "Deployme +nt Management:"); newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 191/mm, $value +Hash{"COP1a"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 184/mm, "Staging +and Logistics of deployed PCs:"); newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 180/mm, $value +Hash{"COP2a"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 173/mm, "Image Lo +ading:"); newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 169/mm, $value +Hash{"COP3a"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 161/mm, "Methods +used to install applications:"); newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 157/mm, $value +Hash{"COP41a"}); newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 153/mm, $value +Hash{"COP42a"}); newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 149/mm, $value +Hash{"COP43a"}); newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 145/mm, $value +Hash{"COP44a"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 138/mm, "User Sta +te Migration:"); newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 134/mm, $value +Hash{"COP5a"}); newText($fontType, 'Roman', 8/pt, 'black', 12.5/mm, 127/mm, "Post Dep +loyment End User Support:"); newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 123/mm, $value +Hash{"COP6a"}); #newText($fontType, 'Roman', 6.75/pt, 'black', 12.5/mm, 123/mm, "Remo +te issue resolution; \"command center\" remotely monitors deployment/ +troubleshoots issues"); ###################################################################### +############################# $page = $pdf->openpage(2); setImage($bubbleName, 115/mm, 100/mm, 89/mm, 75/mm); ###################################################################### +########################## sub newText{ my $flashVars = $page->text; $flashVars->font( $font{$_[0]}{$_[1]}, $_[2] ); $flashVars->fillcolor( $_[3] ); $flashVars->translate( $_[4], $_[5] ); $flashVars->text( $_[6] ); } #################################### sub setImage{ my $photo_file=$pdf->image_jpeg($_[0]); my $photo = $page->gfx; ## add photo to pdf include cordinates and size - image($photo, x, + y, width, hieght); $photo->image($photo_file, $_[1], $_[2], $_[3], $_[4]); } ############ END setImage FUNCTION ################# sub GrabParams{ my ( $paramName, $paramValue); foreach $paramName ($q->param) { $valueHash{$paramName}; foreach $paramValue ($q->param( $paramName )) { $valueHash{ $paramName } = pack 'U0A*', $paramValue; + } } } print $pdf->stringify; binmode STDOUT; $pdf->end; unlink($ChartImageName, $bubbleName); __END__

Comment on (8)Exec format error: when running the script on Linux
Download Code
Re: (8)Exec format error: when running the script on Linux
by andyford (Curate) on Jan 19, 2007 at 18:22 UTC

    Sounds like a problem with a system call or binary.
    What happens if you just run the first part of the program? Just the "#!" and the "use" lines.

    non-Perl: Andy Ford

      the code broke when I put in the following parts:
      print header( "application/pdf" ); use constant mm => 25.4/72; use constant in => 1/72; use constant pt => 1; sub setImage; sub newText; sub newTextRight; sub checkCurrency; sub GrabParams; my $q = new CGI; my %valueHash; GrabParams();
      and this function: <code> sub GrabParams{ my ( $paramName, $paramValue); foreach $paramName ($q->param) { $valueHash{$paramName}; foreach $paramValue ($q->param( $paramName )) { $valueHash{ $paramName } = pack 'U0A*', $paramValue; } } } <code> all though it works on my windows machine.

        Try taking out these:

        sub setImage; sub newText; sub newTextRight; sub checkCurrency; sub GrabParams;
        I don't know what they're for. As far as I know, you don't pre-declare subroutines in Perl.

        non-Perl: Andy Ford

        So GrabParams is the problem? I.e. if you don't call GrabParams() is doesn't fail?
        If that's the case, then maybe you need to look at the pack call. The most basic thing would be to put in some print statements to make sure the params are what you thing they should be.
        Have you run this from the command line or just via the webserver? Maybe something's wrong in the web server infrastructure.

        non-Perl: Andy Ford

Re: (8)Exec format error: when running the script on Linux
by cdarke (Prior) on Jan 19, 2007 at 19:43 UTC
    How are you running the script? If 'perl scriptname' then you probably have a problem with the perl binary, and other perl scripts would not run.
    If you are just typing the name of the script, then check that you do not have any weird characters on the #! line. perl on UNIX should read Windoze style files (\r\n lines), so I doubt that is your problem (or is it a very old version?). Try deleting the first line and typing it again, or do an od -xc scriptname|more and take a peek.
    Failing that, run it under strace (strace perl scriptname) or truss (truss perl scriptname) which should indicate which file it is complaining about.
Re: (8)Exec format error: when running the script on Linux
by ikkon (Monk) on Jan 19, 2007 at 22:22 UTC
    the problem seemed to be that it was windows and unix wasn't liking it I rewrote it and made sure it was Unix file, and it worked, Thanks everyone for the help.
Re: (8)Exec format error: when running the script on Linux
by Anonymous Monk on Apr 11, 2009 at 16:00 UTC

    I came across this thread when Googling on "(8)Exec format error:". This probably not the answer to the question asked... However, I've just had this problem and it turned out that I'd started my script with a newline and not #!/usr/bin/perl (ie I'd opened emacs hit return, then paged down to the bit of code I was working on).

    so the script worked as 'perl foo.pl' but not via apache

    Hope this helps someone.

      I had the same issue, Thank You for the wisdom to solve my issue in such a timely manner. May happiness find you on your travels.
      solved my problem too. thank you very much!
      That is good reason to adopt template
      #!/usr/bin/perl -- #!/usr/bin/perl -w -- #!/usr/bin/perl -Tw -- ...
      -- signals end of options

      I tried what you monks said, but it didn't quite work out for me.
      Until I discovered that some stupid editor inserted the utf-8 byte order mark without asking and thus mangled my shebang into #!/usr/bin/perl

      I had to change the encoding to remove the mark, and now everything works fine :)

        If you are using Notepad++ as your editor and you are using unicode, be sure to have it set to "Encode n UTF-8 without BOM".

        Otherwise, you get that leading character,

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://595516]
Approved by andyford
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2014-07-28 11:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (196 votes), past polls