View Full Version : Php or Html code to execute PERL script
Impromptu
11-11-2013, 11:44 AM
Hi All,
I asked a friend to program me a script, but he did the script in PERL, but he doesn't code online (ie php or html).
Does anyone how to call a PERL script in VB via html or php code?
I tried the PERL script via command prompt and it works (he gave instruction), but I've tried it so many ways in html/php code to execute the PERL script but it won't work.
Thanks in advance.. Jay
parts of the code are below.
#!/usr/bin/perl
use warnings;
use strict;
use URI;
use Web::Scraper;
use HTML::Entities;
use List::MoreUtils 'first_index';
Max Taxable
11-11-2013, 12:37 PM
That code is so old it might have come from Hammurabi. Are you one of the folks trying to fix the Obamacare website?
CGI. (http://www.parkansky.com/tutorials/bdlogcgi.htm)
nhawk
11-11-2013, 07:56 PM
1) Make sure the user php runs as has permission to execute the perl script.
2) Make sure safe_mode is OFF in PHP.
3) This should work in PHP..
exec("sudo perl /path/to/your/script.pl $variables $here");
Impromptu
11-12-2013, 03:30 AM
That code is so old it might have come from Hammurabi. Are you one of the folks trying to fix the Obamacare website?
CGI. (http://www.parkansky.com/tutorials/bdlogcgi.htm)
Not sure what Hammurabi means TBH. I assume Obama Care is some charity organised by the US President, but no I'd be the last person trying to fix any website. As per my post, I don't know how to program (far from it) and asked someone to help me.
Cheers for the link!
--------------- Added 1384237676 at 1384237676 ---------------
Tried in HTML (or PHP) but both didn't work:
lscgid: execve():/clientdata/apache-www/s/u/MYWEBSITEDOMAIN/www/cgi-bin/myscraper.pl: No such file or directory
Any ideas?
#!/usr/cgi-bin/perl -w
# use warnings;
use strict;
use URI;
use Web::Scraper;
use HTML::Entities;
use List::MoreUtils 'first_index';
cellarius
11-12-2013, 08:15 AM
Well, the error message is quite plain: No such file or directory. Your path is wrong.
Impromptu
11-12-2013, 09:04 AM
Well, the error message is quite plain: No such file or directory. Your path is wrong.
Hahaha I know that, but how do I change it...
Sorry I'm a layman in terms of programming...
cellarius
11-12-2013, 09:29 AM
Well, we can't tell you what the correct path to your script on the server is. Try finding out via the pwd shell command (if you have shell access).
nhawk
11-12-2013, 11:02 AM
cgi-bin is almost never in the www directory. It's almost always one below that.
IE:
/clientdata/apache-www/s/u/MYWEBSITEDOMAIN/cgi-bin/myscraper.pl
Hence why safe_mode needs to be off in php.ini.
Impromptu
11-12-2013, 07:17 PM
cgi-bin is almost never in the www directory. It's almost always one below that.
IE:
/clientdata/apache-www/s/u/MYWEBSITEDOMAIN/cgi-bin/myscraper.pl
Hence why safe_mode needs to be off in php.ini.
My webhosting company has confirmed it is not in SAFE MODE.
You can check here: http://supercoachscores.com/phpinfo.php
This is so painful:mad::mad::mad:, but thank you everyone for the help.
Max Taxable
11-12-2013, 10:09 PM
My webhosting company has confirmed it is not in SAFE MODE.
You can check here: http://supercoachscores.com/phpinfo.php
This is so painful:mad::mad::mad:, but thank you everyone for the help.As I joked earlier - you are working with byzantine code- PERL, which went into the bin of technological obsolescence along with floppy disks and audio cassette tapes. This is the 21st Century, Mack and there's no reason I can think of, to call a Perl script.
There's nothing you can do in Perl that can't be done better in PHP so I don't understand why your friend codes in PERL. Does he live in a cave or something? My reference to Hammurabi was trying to say just the above. Hammurabi's code? Never heard of it?
Impromptu
11-13-2013, 01:33 AM
As I joked earlier - you are working with byzantine code- PERL, which went into the bin of technological obsolescence along with audio cassette tapes. This is the 21st Century, Mac and there's no reason I can think of, to call a Perl script.
There's nothing you can do in Perl that can't be done better in PHP so I don't understand why your friend codes in PERL. Does he live in a cave or something? My reference to Hammurabi was trying to say just the above. Hammurabi's code? Never heard of it?
LOL I have no idea.
It should be a simple script as all I want to do is webscrape from a website...I actually tried to self-teach myself PHP but it was too hard...
Okay better question is does anyone know a PHP where you can web scraper data such as NBA rosters, NFL scores etc?
I guess if noone knows how to call a Perl script nor can direct me to a good webscrapping script...might not have this feature :( :( :(
cellarius
11-13-2013, 05:36 AM
Webscraping is something that practically always has to be done custom for the very page you want to scrape. You need to adapt it to it specifically, and you need to cater for any changes that are made to the source website, continously. That's hard if you have no idea yourself, and its even harder in Perl (which every reasonable web dev has long forgotten). Are there no reliable xml sources for the stuff you want?
Anyway, Max is absolutely right - to do this in Perl is like trying to fix a car with a stone axe or write a book with stone and chisel. Still you were told how to call a perl script from php - we do know how to do that. What we don't know and can't know is the correct path and permissions setting on your server.
tbworld
11-13-2013, 05:42 AM
Very elegantly written @Cellarius.
This is really not a programming question, merely a programming task to be completed, and should be re-asked in a 'request' forum.
Impromptu
11-13-2013, 11:10 AM
Webscraping is something that practically always has to be done custom for the very page you want to scrape. You need to adapt it to it specifically, and you need to cater for any changes that are made to the source website, continously. That's hard if you have no idea yourself, and its even harder in Perl (which every reasonable web dev has long forgotten). Are there no reliable xml sources for the stuff you want?
Anyway, Max is absolutely right - to do this in Perl is like trying to fix a car with a stone axe or write a book with stone and chisel. Still you were told how to call a perl script from php - we do know how to do that. What we don't know and can't know is the correct path and permissions setting on your server.
Very elegantly written @Cellarius.
This is really not a programming question, merely a programming task to be completed, and should be re-asked in a 'request' forum.
Thanks fellas,
I actually offered to pay someone to do it for me: https://vborg.vbsupport.ru/showthread.php?t=302075 however, noone wanted the job. Therefore, I asked my mate to do it, but he did it in Perl.
My friend, probably just picked Perl as it was probably just the easiest for him and to be fair the guy has worked for very well known companies but probably just programs in his preferred language.
If anyone wants the job, please PM me https://vborg.vbsupport.ru/showthread.php?t=302075
It's a free website and more of a hobby, so while I'm willing to pay, I'm not willing to pay a fortune LOL.
BTW That's for everyone's responses too
Are there no reliable xml sources for the stuff you want?
Actually tried Mozenda and was thinking of the price, but it didn't work and also refresh was not every 30 seconds..
Checked a few and some were too much or some just didn't work. Some just automate web scraping to the computer and not online..Any suggestions will be appreciated...
While I note your comments about the Perl concerns, to be fair, it actually works in Command or Local format.
Max Taxable
11-13-2013, 03:18 PM
While I note your comments about the Perl concerns, to be fair, it actually works in Command or Local format.My race car engine from 1932 runs great in my garage too. But can't take it out on the road without.. Oh, let's see. A chassis, axles, wheels.... So it really doesn't do me a bit of good running great in my garage.:D
EDIT TO ADD:
You might could let your Geico caveman coder have a look at this (http://www.cs.wcupa.edu/~rkline/perl2php/) and see if he can translate the perl into PHP for you.
He might originally see it as Star Trek stuff, but soon he will realize the similarities and the much expanded horizons this can give him.
I tried the PERL script via command prompt...
Assuming this is Linux you can do a pwd and get the path to your script. People can say whatever they want about Perl, but if it works, who cares.
ETA: oh, just noticed that cellarius already mentioned pwd. I missed it the first time through.
Max Taxable
11-13-2013, 09:36 PM
Bicycles work too. But wouldn't you really rather have a Buick?:D
cellarius
11-14-2013, 06:26 AM
Bicycles work too. But wouldn't you really rather have a Buick?:D
That really depends. I wouldn't want to ride a Buick downhill in the Alps ;)
Impromptu
11-18-2013, 05:28 AM
Thanks for all your help guys.
I decided to pay someone to do it for me :(
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.