Sign in to follow this  
Followers 0
lydon

Processing Text Using Perl/AutoIt

4 posts in this topic

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.

Share this post


Link to post
Share on other sites



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;

Share this post


Link to post
Share on other sites

most implementations of perl are called with -e <scriptname>.

You can use Run or RunWait, among other methodologies.


Reading the help file before you post... Not only will it make you look smarter, it will make you smarter.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0