ScriptFu Posted November 6, 2012 Share Posted November 6, 2012 I am trying to pass the -c parameter to a gzip command, but cannot get autoIt to make it work. Here is the line i am currently using, Run('"C:\Program Files (x86)\GnuWin32\bin\gzip.exe" "C:\Users\fp\Downloads\' & $sLatestFile & '"') This works fine, but it deletes the file after it is zipped. I need it to not delete the file, so i need to use the -c switch. Anyone have any luck getting this to work? Thanks. Link to comment Share on other sites More sharing options...
Bowmore Posted November 6, 2012 Share Posted November 6, 2012 This little script should get you started. It runs gzip with the output redirected to StandardOut and captures the content of StandarOut into a variable and the writes the content of the variable to a new file. #include <Constants.au3> Global $sCompressedData = "" Global $iPID = -1 Global $sLatestFile = "Name of file to compress" ;Run gzip with output to Standard Out $iPID = Run('"C:Program Files (x86)GnuWin32bingzip.exe" -c "C:UsersfpDownloads' & $sLatestFile & '"',@WorkingDir,@SW_HIDE,$STDOUT_CHILD) ; Read the compressed data from StandardOut $sCompressedData = StdoutRead($iPID) While Not @error $sCompressedData &= StdoutRead($iPID) WEnd ; Now write the compressed data to a new file FileWrite("C:UsersfpDownloads" & $sLatestFile & ".gz",$sCompressedData) "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook Link to comment Share on other sites More sharing options...
ScriptFu Posted November 7, 2012 Author Share Posted November 7, 2012 This little script should get you started. It runs gzip with the output redirected to StandardOut and captures the content of StandarOut into a variable and the writes the content of the variable to a new file. #include <Constants.au3> Global $sCompressedData = "" Global $iPID = -1 Global $sLatestFile = "Name of file to compress" ;Run gzip with output to Standard Out $iPID = Run('"C:Program Files (x86)GnuWin32bingzip.exe" -c "C:UsersfpDownloads' & $sLatestFile & '"',@WorkingDir,@SW_HIDE,$STDOUT_CHILD) ; Read the compressed data from StandardOut $sCompressedData = StdoutRead($iPID) While Not @error $sCompressedData &= StdoutRead($iPID) WEnd ; Now write the compressed data to a new file FileWrite("C:UsersfpDownloads" & $sLatestFile & ".gz",$sCompressedData) Did this work for you? I tried and it did run, but it did not compress the file. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 7, 2012 Moderators Share Posted November 7, 2012 Have you looked at: Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
ScriptFu Posted November 7, 2012 Author Share Posted November 7, 2012 Have you looked at:I have, but that still does not use the -c switch. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 7, 2012 Moderators Share Posted November 7, 2012 (edited) No idea what -c switch is, not going to hunt it down either. So.. Bowmore's looks correct unless the working directory is incorrect. If the second file command line is actually what you're trying to write to, and if the gzip.exe already does that, no need for stdout, so you could do: Run('"C:Program Files (x86)GnuWin32bingzip.exe" -c "C:UsersfpDownloads' & $sLatestFile & '"', @WorkingDir) If that doesn't work, you could try: Run('"C:Program Files (x86)GnuWin32bingzip.exe" -c "C:UsersfpDownloads' & $sLatestFile & '"', '"C:Program Files (x86)GnuWin32bin"') Edited November 7, 2012 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now