Is there anything like Ruby on Rails' script console for Perl's Catalyst? From rubyonrails.org:
The console command lets you interact with your Rails application from the command line. On the underside, rails console uses IRB, so if you’ve ever used it, you’ll be right at home. This is useful for testing out quick ideas with code and changing data server-side without touching the website.
I found a blog post talking about implementing it with Devel::REPL, but I cannot get it to work...
No. And, for that matter only a very small percentage of Perl users use opt for the Perl debugger at all -- this is largely because it's faster to execute and throw an exception, and because of the total transparency of Perl Objects -- they're just blessed Hashes and they serialize into strings pretty well.
I happen to like XXX, drop an
use XXX;
XXX \%hash;
or do a Catalyst::Exception->throw( YYY %v );
I've been using CatalystX::REPL with success. I'm not familiar with the RoR console but, basically, CatalystX::REPL will drop you into an interactive environment where you can inspect the application's context object and so on.
Related
I'm looking to write a script that lets a user upload an image from a webpage, for later use on that website. As per usual, all I can find is examples involving CGI.pm. Are there any core modules that I can use as a replacement?
The Perl core distribution contains no modules for writing web applications. I think you probably want something based on Plack::Request and Plack::Request::Upload (for example Dancer2::Core::Request::Upload).
The solution I ended up going with may not be the best, but it's functioning, and simple.
Using cgi-lib.pl I can simply use
open(VAR, ">output/file.png");
binmode VAR;
print VAR $in{input};
close(VAR);
and it gets the job done.
If there are any notable problems with this, please let me know.
I have a fully functional perl script which talks to our SOAP webservice. Today it does that via the SOAP::Lite->service('.../name?WSDL') and then a call to execute() against the returned value. They're now locking down the WSDL so when I hit that I get a 403 error back.
I'm looking for pointers on how to change my script so that it no longer uses the WSDL to figure things out. I do have access to the WSDL itself to look at anything I need to know, but the perl script no longer will.
Since you have the WSDL file, you can use the local copy of it to drop right in with no other changes to your code:
my $soap = SOAP::Lite->service("file:localcopy.wsdl");
If you don't mind switching to SOAP::WSDL, it includes wsdl2perl.pl which will generate all of the perl packages for you:
wsdl2perl.pl file:localcopy.wsdl
I'm very new to Perl, and I have absolutely no idea how to approach this. We have an old Perl application which previously used Apache auth; we'd like to replace this with a cookie based form-style authentication. I understand that this is very case-specific, and there is no one answer as such, but some general tips would be much appreciated.
Will I need to edit all .pl files in the website? Or is there a "golden hammer" solution I can use? Is there something on CPAN I can use? We're using Perl v5.8.8 if it matters, and we're using Apache 2 shared hosting. I am happy to provide additional information as is necessary.
For the authentication to be recognized/required, it will need to be checked by the .pl file that initially receives the user's request. So the answer to whether all .pl files will need to be changed depends on how your application is structured:
If the user goes to http://myserver.com/one.pl to do the first thing and http://myserver.com/two.pl to do the second thing, then, yes, you'll need to change them all because they're all receiving requests individually.
If the user goes to http://myserver.com/dispatch.pl?mode=one for the first thing and http://myserver.com/dispatch.pl?mode=two for the second thing and dispatch.pl calls either one.pl or two.pl behind the scenes based on the mode parameter, then you only need to change dispatch.pl, since it's the only one directly receiving requests from the user.
Edited to add: If you're dealing with the first model, then I'd strongly recommend setting up an external module (.pm file) with the cookie-handling code and calling that from each of your individual .pl files instead of duplicating that code all over the place. Ideally, this would let you get by with only a few lines of added code in each .pl:
use MyCookieHandlingModule qw(verify_cookie redirect_to_login);
my $q = CGI->new; # ...unless you're already using CGI in object-oriented mode
redirect_to_login unless verify_cookie($q);
You could do it at a level outside the Perl program.
Thanks for your answers guys, but I eventually decided on CGI::Session::Auth::DBI which works well on shared hosting.
I want to download some Yahoo Groups (files, photos, messages, memberlist) and I've found these scripts:
http://freshmeat.net/projects/grabyahoogroup/
http://sourceforge.net/project/showfiles.php?group_id=62034
I've downloaded ActivePerl and the needed modules from CPAN (nothing fancy; they're very easy to find). I've managed to install them, but when I run the script I get an error after it tells me that I've successfully logged in:
"Use of uninitialized value $cells in pattern match (m//) at yahoogroups_files.pl line 244, line 2."
I'm guessing that Yahoo changed the layout of the page or something, but I'm not able to update the script myself. I'm a newbie when it comes to Perl and understanding the way Yahoo generates the pages, I only know some basic C++. I want to mention that I'm not lazy, I'll try do fix it myself but I need your help: hints, advice, anything.
PS: I've contacted the author, but he isn't willing to update the scripts.
You would need knowledge in the following fields:
use of an html parser
http knowledge ( get/post/head )
web scraping
I suggest you focus on WWW::Mechanize since it's capable of all these things ( and more )
EDIT: another solution ( that doesn't need programming ) , is this: login with your browser on yahoo groups, store the cookie, and then run wget , passing the stored cookie as a parameter. This way you'll get the task accomplished very fast.
Find your browser's cookies.txt file on your harddrive, and then call wget like this ( if I remember the commands correctly ) :
wget --load-cookies path_to_cookie_file -r -w 60 website
The full man page can be found here
EDIT2: Another option is to use WebDriver to automate firefox. You can use this article as a guide on how to accomplish this.
By the filename I'm assuming you're using Yahoo Group archiver found here: http://sourceforge.net/projects/grabyahoogroup/
I ran the files script against the SubEthaEdit group and it works great. All of the files downloaded without incident.
Looking at the code it seems to barf while processing an html table in a while loop if $cells is empty.
Considering the code did work when I tested it it's possible there's something going on with the listing of that group's files. You'll want to try outputting $content and figure out where and why the regular expression on 243 isn't able to process that html.
EDIT: If you don't mind posting the group this is happening with I'm sure myself or someone else here can try it out and troubleshoot on their own. It's tough to pinpoint what's up when the issue can't be duplicated. Also, try the same group I did and see if it works out for you. Certainly something up with the group you're trying if that works.
Dunno if it will help you, but here's what I did to get the message-download working:
http://sourceforge.net/forum/forum.php?thread_id=3283915&forum_id=209170
(I only used message-download, I didn't look at file-download)
Was tinkering on this a while ago to backup my girlfriend's group messages and files from uni. Upon debugging on the latest scripts I've found out that there seems to be a bug on group_domain declaration (theres also a group declaration bug that i've found on yahoo2maildir.pl of the same project, see $request)
($group_domain) = $url =~ /\/\/(.*?groups.yahoo.com)\//;
in this case, i've overwritten the $request var under the function sub download_folder() with
from <br>
$request = GET "http://$group_domain/group/$group/files$sub_folder/";
<br> to <br>
$request = GET "http://**groups.yahoo.com/group/$user_group**/files$sub_folder/";
grabyahoogroup works well in the latest edition, which can be found at the svn repo:
http://grabyahoogroup.svn.sourceforge.net/viewvc/grabyahoogroup/trunk/yahoo_group/
The version at sourceforge.net/projects/grabyahoogroup/files/ HAS BUGS AND DID NOT WORK FOR ME.
I've been looking for a tool that collects messages/conversations from Yahoo Groups!. I finally found this tool that converts your Yahoo! Groups messages into MBOX format after struggling to try to make my own and searching everywhere on the internet.
Download tools
Both of the following are Google Chrome extensions.
Chrome Extension to Download Members posted by Sam Hobbs (2015).
Chrome Application To Download Messages posted by Mark Fletcher (Jan 2016).
Plain string to Base64 binary data
At some time past September 16, 2010 (at least for me), the messages retrieved are no longer plain text and instead Base 64 binary data (ASCII). Using this swiss converter tool can allow you to read the data as it is.
Sample content from the MBOX format
VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy4=
Sample result after conversion
The quick brown fox jumps over the lazy dog.
for cause, as of 2019/09
https://github.com/csaftoiu/yahoo-groups-backup
.....
I have an AIR application that takes command-line arguments via onInvoke. All is good, but I cannot figure out how to print some status messages back to the user (to stdout / console, so to speak). Is it possible?
Even a default log file for traces would be fine, but I can't find any info about it anywhere. Do I need to create my own log file? Now that'd be silly.
Take a look at CommandProxy. It is a low level wrapper around your AIR application that lets you send command from AS3 back to the proxy for communicating with the underlying OS. You should be able to add a means of writing to the command line via such a method.
I don't think that is possible, but I'm not completely sure though.
There is a flashlog.txt file which you can configure so all trace() statements are logged to it. Check this post http://www.digitalflipbook.com/archives/2005/07/trace_from_the.php for more info on how to set it up. This is for logging from the browser, but I'm pretty sure it should also work from an air app.
Additionally, you could use SOS MAX from Powerflasher to log to an external console through an XML socket.
By default, trace() will output to stdout.
Your AIR application is one, big trace window if you want it to be.