Sign in to follow this  
Followers 0
SpecialK99

Running a Windows program and piping output to a textfile

2 posts in this topic

Hi

I'm new to AutoIt and am trying to convert some Perl scripts to AutoIT.

I have a Perl script to backup some files using WinZIP command line program (WZZIP) and pipe the text output to a logfile.

I then examine the logfile for any errors.

I've managed to convert the script to AutoIT and I can get it to call WZZIP and create the required ZIP file.

But instead of the output being piped to a logfile (e.g. " > logfile.txt") the carat character ">" is being interpreted by WinZIP as a additional file to backup and results in a WinZip error saying there is no file called ">" to backup, the same thing occurs with the "logfile.txt" reference. Consquently all the text output from WinZip of what files are being backed up is going to the console window rather than a text file.

It looks like the AutoIT Run command is calling WinZip but "> Log. txt" is being interpreted as parameters by Winzip rather than a piped command. Yet this type of call works in Perl.

Here's part of my code

$dt1 is todays date

$tm1 is the time now

The above date/time works fine, it's just the piping output I'm having a problem with

# Zipfile name
$zip1 = "Agent_" & $dt1 & "_" & $tm1 & ".zip"

# Path to output directory
$pth1 = "C:\My Files\Install 1\"

# Directory to backup
$pth2 = "C:\Documents and Settings\Special K\My Documents\COMMSbase\Agent\Data\*.*"

# WinZip program
$prg1 = "C:\My Files\Utilities\WinZip\WZZip"

# WinZip options
$opt1 = "-a -p -rP"

# Concatenate output path and Zipfile name
$zip2 = $pth1 & $dt1 & "_" & $dy2 & $zip1

# Logfile
$log1 = $pth1 & $dt1 & "_" & $dy2 & "\Agent_" & $dt1 & "_" & $tm1 & "_Log.txt"

ConsoleWrite( $tm1 & " Backup Agent files..." & @CRLF )
ConsoleWrite( "Filename: " & $zip1 & @CRLF )

Run( $prg1 & " " & $opt1 & " """ & $zip2 & """ """ & $pth2 & """ > """ & $log1 & """" )

Should I be using a different command than "Run" to call WinZIP as I have the pipe embedded in the call ?

Share this post


Link to post
Share on other sites



Maybe helps.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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