Date: Wed, 7 Sep 2011 12:00:57 -0700
Reply-To: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Nordlund, Dan (DSHS/RDA)" <NordlDJ@DSHS.WA.GOV>
Subject: Re: CALL SYSTEM and Long file names in Windows
In-Reply-To: <AC5F423B9AB19C43BE62C86BAF8113CC1099EF@WABOTH9MSGUSR8C.ITServices.sbc.com>
Content-Type: text/plain; charset=utf-8
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> DUELL, BOB
> Sent: Wednesday, September 07, 2011 11:25 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: Re: CALL SYSTEM and Long file names in Windows
>
> Hi Jeff,
>
> Very close. You need to surround the Windows file names with double
> quotes, not single quotes. Although I don't use Winzip, I do use GNU
> zip. This is from a daily production job:
>
> cmdline = '"C:\Program Files\GnuWin32\bin\zip" -mj'
> || ' "\\us.cingular.net\dfsroot\HQ\WWD\DEPT\DBM_Rpts\ROCCS
> Reporting\ROCCS 222 Summary\'
> || "&rpt_save_file"
> || '.zip"'
> || ' "C:\Bob\ROCCSRPT\' || "&rpt_save_file" || '.xls"';
> rc = system(cmdline);
>
> Bob
>
> -----Original Message-----
> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
> Kroll, J. (Jeffrey)
> Sent: Wednesday, September 07, 2011 10:58 AM
> To: SAS-L@LISTSERV.UGA.EDU
> Subject: CALL SYSTEM and Long file names in Windows
>
> Im trying to run the following and its just not recognizing the long
> names. Can anyone tell me what Im doing wrong?
>
> All macro variable are defined prior to this.
> data _null_ ;
>
> zipexe='C:\Progra~1\WinZip\Winzip32.exe -min -a' ;
>
> zipfile="'W:\Shared Documents\&folder\&name._&mon..zip'" ;
>
> file="'C:\Temp\&name._&mon..xls'";
>
> cmd2=zipexe || ' ' || zipfile || ' ' || file ;
>
> putlog "NOTE-Processing command " cmd2 ;
>
> call system( cmd2 ) ;
>
> run ;
>
> Winzip just doesnt like these file name. It tries to create
> W:\Shared.zip. Ive also run this without the single quotes around the
> file names. Still didnt work.
Just to put a cap on Bob's advice, the double quotes are required around file names which have spaces in them. That is true for both programs you are running, and file names that are parameters. In addition, you can't have a single set of double quotes around a program name and the parameters you are passing to the program. For example, you defined zipfile using the short name. You could have used the long filename something like:
zipexe='"C:\Program Files\WinZip\Winzip32.exe" -min -a' ;
Note, the parameters -min and -a are outside the double quotes.
The other problem you might still have is that macro variables will not resolve inside single quotes, so you can't use single quotes at all when defining a string that includes macro variables that you want to resolve. So for example, your zipfile variable would need to be defined as
zipfile="""W:\Shared Documents\&folder\&name._&mon..zip""" ;
Notice the three double quotes at the beginning and the end. The first and last double quotes define the beginning and the end of the string. Quotes 2 and 3 resolve to just one double quote inside the string (as do quotes 4 and 5). Now your macro variables will resolve, and you are left with double quotes surrounding the file name when it gets to the command line.
Hope this is helpful,
Dan
Daniel J. Nordlund
Washington State Department of Social and Health Services
Planning, Performance, and Accountability
Research and Data Analysis Division
Olympia, WA 98504-5204
|