Please help: Perl script to automate repetative task - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Please help: Perl script to automate repetative task

QuicheQuiche Posts: 3Member
Hi all. I have been using macro scripts to automate tasks at work which is great and saves a lot of time IF I leave my computer on all the time. I am wanting to have a simple script of some kind that I can execute hourly with a cron job that will allow me to host it on an internal server so the macro task will be repeated from that instead of relying on my computer being left on all the time.

Is this possible? All it has to do is log into a designated webpage and click a submit button on a GET form in a php page. I am a complete dunce with scripting otherwise I would not need to ask, obviously. Thanks in advance for anyone kind enough to help out with this. I can provide most of the required data I think by reading the raw http requests involved in the process.

Comments

  • JonathanJonathan Posts: 2,914Member
    Hi,

    Check out the Perl module LWP::UserAgent:

    http://search.cpan.org/~gaas/libwww-perl-5.808/lib/LWP/UserAgent.pm

    Which should make this easier for you. Or maybe also WWW::Mechanize.

    http://search.cpan.org/~petdance/WWW-Mechanize-1.34/lib/WWW/Mechanize.pm

    Jonathan
    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
  • QuicheQuiche Posts: 3Member
    Thanks for your response. That Mechanize thing looks to be the business. Now I just have to figure out how to make it do what I want. I guess now is as good a time to learn perl :)


    : Hi,
    :
    : Check out the Perl module LWP::UserAgent:
    :
    : http://search.cpan.org/~gaas/libwww-perl-5.808/lib/LWP/UserAgent.pm
    :
    : Which should make this easier for you. Or maybe also WWW::Mechanize.
    :
    : http://search.cpan.org/~petdance/WWW-Mechanize-1.34/lib/WWW/Mechanize
    : .pm
    :
    : Jonathan
    : ###
    : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • QuicheQuiche Posts: 3Member
    Gah. I'm having a tough time even programming this. No surprise really since I'm not a programmer and just wanted it to make life at work a bit easier. Is there any existing scripts for this kind of thing already floating around? I've checked out hotscripts but no luck so far. Thanks.

    : Thanks for your response. That Mechanize thing looks to be the
    : business. Now I just have to figure out how to make it do what I
    : want. I guess now is as good a time to learn perl :)
    :
    :
    : : Hi,
    : :
    : : Check out the Perl module LWP::UserAgent:
    : :
    : : http://search.cpan.org/~gaas/libwww-perl-5.808/lib/LWP/UserAgent.pm
    : :
    : : Which should make this easier for you. Or maybe also WWW::Mechanize.
    : :
    : : http://search.cpan.org/~petdance/WWW-Mechanize-1.34/lib/WWW/Mechanize
    : : .pm
    : :
    : : Jonathan
    : : ###
    : : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    : : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    : : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");
    :
    :

  • HackmanCHackmanC Posts: 441Member
    You could try to use lwp-rget or lwp-request from (ActiveState) Perl distribution. Also you have the source code if you need further modifications.

    If you are a Unix/Linux/Solaris etc. user, try to locate in your current installation, (:~$ locate lwp-rget). Or find the package in your distro.

    from lwp-request man page:

    DESCRIPTION
    This program can be used to send requests to WWW servers and your local
    file system. The request content for POST and PUT methods is read from
    stdin. The content of the response is printed on stdout. Error mes-
    sages are printed on stderr. The program returns a status value indi-
    cating the number of URLs that failed.

    An example (by the way):

    :~$ lwp-request http://www.domain.com/page.cgi < [stdin post] | grep | mail ... etc ... etc ...

    [red]Good luck![/red]
    [blue]Hackman[/blue]
Sign In or Register to comment.