Jump to content
Sign in to follow this  

7za And STDOUT Problems

Recommended Posts

Can't seem to get past this...been working on a new backup script for work and I've got the process down, but now I'm looking to impliment logging. Here's what I have so far:

R7ZBAK ( "D:\" , "Test" )

Func R7ZBAK ( $R7ZDL , $R7ZNAME )
    Dim $R7ZDEST
    $R7ZDEST = "K:\Temp\" & @YEAR & "." &  @MON & "." &  @MDAY & "\"

    RunWait ( "7za.exe a -t7z -mx=9 " & $R7ZDEST & $R7ZNAME & ".7z " & $R7ZDL & $R7ZNAME )
;RunWait ( "wcl_ftp.exe " & $R7ZNAME & ".7z " & $R7ZDEST & $R7ZNAME & ".7z put 1 1 0 1 0 0" )
    FileMove ( @ScriptDir & "\wcl_ftp.log" , @ScriptDir & "\" & @YEAR & "." &  @MON & "." &  @MDAY & "-" &$R7ZNAME & ".log" )
    Run ( "localsrv.exe" )
;RunWait ( "blat.exe " & @YEAR & "." &  @MON & "." &  @MDAY & "-" &$R7ZNAME & ".log -t -server localhost" )
    Sleep ( 1000 )
    ProcessClose ( "localsrv.exe" )

I've edited some lines to remove sensitive login info.

The idea is to allow me to enter in the path and then have the function compress and then ftp it to another server. The ftp log is handled fine, as it outputs to a file. But with 7za.exe it can only output to StdOut and StdErr by adding ">> logfile.txt" at the end of the command. If I run that new code outside of AutoIt it works, creating a log file. But when I try to impliment that into the script it doesn't write the log file but finishes fine otherwise.

Since I'm very limited in my abilities I assume it's something in the way I have things setup, but I also think it could be with the autoit script blocking output/input to stderr...is there a way to manually turn off that feature? I've searched all over to find more, and it looks like the only current options as of the latest beta are in the Run command, the last option.

So if someone could advise on the best way to get the log from 7za I would really like that. If I could somehow run the script and have AutoIt capture all the info that would be cool, but I can't figure that out either. The intent of the script will be to eventually run the function multiple times using different locations.

And while I'm here, does that structure look correct in regards to what I'm trying to do?


Share this post

Link to post
Share on other sites

Firstly, thanks for reading the docs. Here's the gotcha: the console-redirection-append-to-file feature a-la >> out.txt is a feature of the command interpreter COMMAND.COM or CMD.EXE, in order to take advantage of it from AutoIt you'd have to include it in your calls to Run like:

; @ComSpec macro evaluates to the full path to the command interpreter
; @ComSpec /c means run a single command then exit
RunWait ( @ComSpec & " /c 7za.exe a -t7z -mx=9 " & $R7ZDEST & $R7ZNAME & ".7z " & $R7ZDL & $R7ZNAME & " >> 7zip.log" )

The above is untested, in a working example it would be better to use a full path to your 7Zip EXE or to specify the working directory.


Yes yes yes, there it was. Youth must go, ah yes. But youth is only being in a way like it might be an animal. No, it is not just being an animal so much as being like one of these malenky toys you viddy being sold in the streets, like little chellovecks made out of tin and with a spring inside and then a winding handle on the outside and you wind it up grrr grrr grrr and off it itties, like walking, O my brothers. But it itties in a straight line and bangs straight into things bang bang and it cannot help what it is doing. Being young is like being like one of these malenky machines.

Share this post

Link to post
Share on other sites

Wow, it was that simple...I thought I only had to use the ComSpec macro when it's a built-in command, but I can see by your explanation how that applies to this. Just plugged it in and it worked...thanx ever so much!

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...