03-19-2014 08:33 AM
Does anyone knwo how to extract a file using RAR that is password protected. I have the below code but this doesn't seem to work.
unzipcmd='"C:\Program Files\WinRAR\RAR.exe" -min -e -o -s' ;
cmd=unzipcmd || pw || ' ' || zipfile || ' ' || whereto || ' ' || file ;
putlog "NOTE-Processing command " cmd ;
call system( cmd ) ;
03-19-2014 09:09 AM
Well, I don't have WinRAR installed so I can't check this, but I can see at least one error in the string you pass to system:
"C:\Program Files\WinRAR\RAR.exe" -min -e -o -sa H:\*.rar H:\test\* ae.sas7bdat
If you check out the command line parameters manual at:
You will see that a password should be supplied with the -p switch not the -s switch. Also I think you have list of files and extract path swapped over.
I would recommend reading the guidance there and getting it to work in dos first. Then once you have a string that works there, then reverse engineer that string in your SAS code.
03-19-2014 09:48 AM
Use a PIPE instead of SYSTEM or X command so that you can retrieve any console messages your called program tried to generate.
cmd = '.......';
infile cmd pipe filevar=cmd end=eof ;
03-19-2014 10:31 AM
I'm fairly new to SAS and ripped the code from the internet, I'm not sure what you code does or how to make it work.
Can you provide a dumbies version?
03-19-2014 10:41 AM
Just put the command you want to run into the variable specified in the FILEVAR= option of the infile statement. The same as you tried to do in preparation for calling the SYSTEM( ) command.
For example to see a list of the RAR files on your drive the command could be "dir H:\*.rar".
cmd = "dir H:\*.rar" ;
infile dummy pipe filevar=cmd ;
If you only want to run one command and it does not require data step coding to construct the command then you can put the command where you would normally place the physical filename in the INFILE statement.
infile "dir H:\*.rar" pipe ;