Jump to content

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" )
EndFunc

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?

Thanx!

Link to comment
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.

Cheers!

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.

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...