Jump to content

Processing Text Using Perl/AutoIt


lydon
 Share

Recommended Posts

I'm needing to process a log file for the tape backups at work. I have a PERL script that I have working perfectly and it processes the logs, and then writes a text file with the servername of each server that needs to be manually checked. All of this works great. I am left with a file something like this:

SERVER1

SERVER2

SERVER3

I need to reprocess that file ^^ and use each line as in input in an AutoIt Script (which is also working) that will manually get rid of the errors from the backup so they will run the next night. So, I pretty much either need AutoIt to take each line of that text file (could be different number of lines every day) and store it as a variable to Send($servername) later on in the script, or I need to use the AutoIt functions in PERL (My preferred method, but my mind is open). My problem is I can't get the AutoIt stuff to work in PERL. I have installed the Win32:API and Win32:OLE PERL Extensions through PPM (as I posted http://www.autoitscript.com/forum/index.php?showtopic=13708) but it still gives me the error: "Undefined subroutine &main::new called at C:\date.pl line 6, <DATA> line 164.

Here is the code: (This is just a test to attempt to get AutoIt to work in PERL)

#!/usr/bin/perl -w
############################################
use win32;
use win32::API;
use win32::OLE;
my $Au3 = win32::OLE-new("AutoIt3x.Control");
$Au3->MsgBox("AutoIt", "AutoIt Seems to be Working");
#############################################

Any help, ideas, or advice on how to get this done will be greatly appreciated. As I said earlier, I am open to other solutions.

Link to comment
Share on other sites

  • 2 years later...

I have been able to use Cygwin with Perl installed and am calling AutoIT scripts by using a backtick to run the AutoIT scripts. Below is one particular script I am using. The only thing I have not figured out is how to run Perl from AutoIT... only run AutoIT from Perl. I'm assuming you're trying to run AutoIT from Perl and not the other way around. Below is a Perl script in the Cygwin (a free download) with Perl installed. Within this Perl script I have been able to call the AutoIT scripts I want to run. I wish I could go the other way around for some other testing though, but have not figured this out yet. Note that I have Perl installed on a Windows XP machine.

#!/usr/bin/env perl

# This script requires having cygwin, and Perl installed

# It sets up the path for the Logger Pro startup file

# and is used to launch any Autoit executables used in

# testing the preferences dialog in Logger Pro

open(LOG, ">>Script_Log.txt") || die ("Can not open Script_Log.txt file.");

print LOG " \n";

print LOG "* * * STARTING preferences.p1 SCRIPT * * *\n";

print "* * * * * * * * * * * * * * * * * * * * *\n";

print "* *\n";

print "* EXECTUTING CURVE_FIT_PREFERENCES *\n";

print "* *\n";

print "* * * * * * * * * * * * * * * * * * * * *\n";

`run curve_fit_preferences.exe`;

# The following is designed to search for Asserts in the

# Logger Pro log files that are created in the Experiment

# folder. Asserts will be appended to the end of Script_Log.ext

print LOG "----------- END OF AUTOIT TEST ----------\n";

print LOG "-- searching Logger Pro log files for asserts\n";

`grep -H 'Assert' "../Logger Pro 3/Experiments/"*.txt >> Script_Log.txt`;

# Run the Autoit script which moves the logger pro log files to test automation folder

`run MoveLogs.exe`;

print LOG "* * * * EXITING startup_preferences.pl SCRIPT * * * *\n";

# the following command closes the cmbl-list.txt file

close INFILE;

close LOG;

print "* * * * * * * * * * * * * * * * * * * * * * *\n";

print "* *\n";

print "* CURVE_FIT_PREFERENCES SCRIPT COMPLETED *\n";

print "* *\n";

print "* * * * * * * * * * * * * * * * * * * * * * *\n";

Exit;

Link to comment
Share on other sites

  • 1 month later...

I see that this is a really old topic. However in case someone comes across it, below is a working example.

#!/usr/bin/perl -w
############################################
use Win32;
use Win32::API;
use Win32::OLE;
my $Au3 =Win32::OLE->new("AutoItX3.Control");
$start = time();
while ((time() - $start) < 10){
$Au3->ToolTip("Hello from Autoit",$Au3->MouseGetPosX(),$Au3->MouseGetPosY());
select(undef,undef,undef,0.10);
}
$Au3->ToolTip("");
#############################################

It creates a tooltip that follows the mouse around for about 10 seconds.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...