#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Cape Town, WP, South Africa
    Posts
    39
    Rep Power
    15
    Hi there

    My script wont excecute is there anybody got any ideas

    #cerlbinperl.exe;

    use CGI;
    use DBI;

    $q = new CGI;


    $dir = $q->param('direction');

    $month = $q->param('month');

    if($dir eq 'e' | | $dir eq 'n')
    {$monex = $month}



    if($dir eq 's' | | $dir eq 'w' )
    {$monimp = $month}


    if ($monex > 0)
    {$qline = "((Max(DatePart('m',[Port Departure Date])))= $monex))";
    }
    elsif ($monimp > 0)
    {$qline = "((Min(DatePart('m',[Port Arrival Date])))= $monimp))";
    }

    if($month == 1)
    {$monthead = 'January'}
    elsif($month == 2)
    {$monthead = 'Febuary'}
    elsif($month == 3)
    {$monthead = 'March'}
    elsif($month == 4)
    {$monthead = 'April'}
    elsif($month == 5)
    {$monthead = 'May'}
    elsif($month == 6)
    {$monthead = 'June'}
    elsif($month == 7)
    {$monthead = 'July'}
    elsif($month == 8)
    {$monthead = 'August'}
    elsif($month == 9)
    {$monthead = 'September'}
    elsif($month == 10)
    {$monthead = 'October'}
    elsif($month == 11)
    {$monthead = 'November'}
    elsif($month == 12)
    {$monthead = 'December'}



    print $q->header;
    print "<html>
    <head>
    </head>
    <body>
    <h1>$monthead DRS Voyages </h1><br>
    <h2>Direction = $dir</h2>
    <table>
    <tr>
    <th>Voyage</th><th>Date</th>
    </tr>";

    $dbh = DBI->connect('DBI:ODBC:salesforecast',' ',' ')
    &#0124; &#0124; die print "cant connect to ODBC";

    $sth = $dbh->prepare("SELECT Schedule_Auto_Report.[Voyage Identifier],
    [Voyage Direction].[Voyage Direction],
    Schedule_Auto_Report.Route,
    Min(Schedule_Auto_Report.[Port Arrival Date]),
    Max(Schedule_Auto_Report.[Port Departure Date]),
    Min(DatePart('m',[Port Arrival Date])),
    Min(DatePart('yyyy',[Port Arrival Date])),
    Max(DatePart('m',[Port Departure Date])),
    Max(DatePart('yyyy',[Port departure Date]))
    FROM Schedule_Auto_Report
    INNER JOIN [Voyage Direction]
    ON Schedule_Auto_Report.[Voyage Identifier] = [Voyage Direction].[Voyage Identifier]
    WHERE (((Schedule_Auto_Report.[Port Code]) Like 'za*'))
    GROUP BY Schedule_Auto_Report.[Voyage Identifier],
    [Voyage Direction].[Voyage Direction],
    Schedule_Auto_Report.Route
    HAVING ((([Voyage Direction].[Voyage Direction])='$dir')
    AND $qline")&#0124; &#0124; die print "the query is the problem";

    $sth->execute &#0124; &#0124; die print "cant excecute";

    while (@row=$sth->fetchrow) {
    print "<tr><td>$row[0]</td>
    <td>$row[3]</td></tr>";
    }

    print "</table>
    </body>
    </html>";

    $sth->finish;
    $dbh->disconnect;
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Posts
    81
    Rep Power
    15
    Two things:

    1) Windows doesn't recognise the #!<command interpreter> syntax at the start of the document. You'll have to run the script as perl <scriptname>

    2) If you were on a unix system, it wouldn't work because that first line has to start #! and not just #

    If you don't like having to manually invoke the perl interpreter every time you want to use your script, write a batch script to do it.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    0
    Rep Power
    0
    I concur with christuckers reply. In case you aren't familiar with writing the batch file. Open notepad and simply type the following: cerlbinperl.exe scriptname

    Your scriptname that is. Save as scriptname.bat (Make sure you drop the file types drop down list to 'All Files' versus '.txt' files. Now place the batch file in a directory that is in your path or add a path to your system and simply type your scriptname (scriptname.bat?) and your good to go. Only thing is, you'll have to either modify it when you do another script of create a new batch. Good Luck.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Cape Town, WP, South Africa
    Posts
    39
    Rep Power
    15
    Thanks for the reply

    I put the path in the autoexec.bat. And that seems to work fine I have already run several scripts.

    So do I not need to include the shabang

    I think this is a different problem
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    73
    Rep Power
    15
    Hi
    in the control panel ODBC Data Sources - is the Data source name 'salesforecast' and is this pointing at the database you wish to query ?
    this is the only think I can see that could be wrong with this - devshed seems to put a gap between the or operator | | so I'm assuming this is correct on the original script.
    did you set up the file associations (eg .pl or .cgi open with perl)


    I have run this on my windows machine and it works fine ( i did replace the complex select statement with a simple one on to one of my own databases)



    [This message has been edited by des (edited November 10, 2000).]
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Cape Town, WP, South Africa
    Posts
    39
    Rep Power
    15
    thanks for the reply

    I have been running scripts on my machine for a while now, so it is nothing to do with perl and the perl installation. This is one of those truly bizzare things that just don't work. I think my sql statement must be faulty.

IMN logo majestic logo threadwatch logo seochat tools logo