DATA Step, Macro, Functions and more

Quoting program name & file path argument in filename pipe on Windows

Reply
Super Contributor
Posts: 376

Quoting program name & file path argument in filename pipe on Windows

Hi,

SAS 9.2 on Windows XP

I'm trying to run this code:

options ls=max;

filename foo pipe " ""C:\Program Files\sysinternals.com\handle.exe"" -u ""%sysfunc(pathname(work))"" ";

data _null_;

  infile foo;

  input;

  putlog _infile_;

run;

filename foo;


I need to pass a quoted path to the program since it has a space in the path.  I need to pass a quoted file path to handle because the tildes in the short path throw off the program.  My actual program will use the %sysfunc(pathname(whatever)) function to get the pathname to an allocated library, which might contain a space or a tilde (if the short name is returned).

I get this error:

1304 options ls=max;

1305 filename foo pipe " ""C:\Program Files\sysinternals.com\handle.exe"" -u ""%sysfunc(pathname(work))"" ";

1306 data _null_;

1307 infile foo;

1308 input;

1309 putlog _infile_;

1310 run;

NOTE: The infile FOO is:

Unnamed Pipe Access Device,

PROCESS="C:\Program Files\sysinternals.com\handle.exe" -u "C:\DOCUME~1\sbass\LOCALS~1\Temp\SAS Temporary Files\_TD2556",

RECFM=V,LRECL=256

Stderr output:

'C:\Program' is not recognized as an internal or external command,

operable program or batch file.

NOTE: 0 records were read from the infile FOO.

NOTE: DATA statement used (Total process time):

real time 0.06 seconds

user cpu time 0.00 seconds

system cpu time 0.00 seconds

Memory 188k

OS Memory 16240k

Timestamp 26-Oct-11 18:10:31

If I cut and paste the text from PROCESS= into a cmd window it works fine:

C:\>"C:\Program Files\sysinternals.com\handle.exe" -u "C:\DOCUME~1\sbass\LOCALS~1\Temp\SAS Temporary Files\_TD2556"

Handle v3.41
Copyright (C) 1997-2008 Mark Russinovich
Sysinternals - www.sysinternals.com

sas.exe            pid: 2556   INTERNAL\sbass             33C: C:\DOCUME~1\sbass\LOCALS~1\Temp\SAS Temporary Files\_TD2556\regstry.sas7bitm
sas.exe            pid: 2556   INTERNAL\sbass             40C: C:\DOCUME~1\sbass\LOCALS~1\Temp\SAS Temporary Files\_TD2556\_tf0001.sas7bitm
sas.exe            pid: 2556   INTERNAL\sbass             668: C:\DOCUME~1\sbass\LOCALS~1\Temp\SAS Temporary Files\_TD2556\sasmacr.sas7bcat
sas.exe            pid: 2556   INTERNAL\sbass             67C: C:\DOCUME~1\sbass\LOCALS~1\Temp\SAS Temporary Files\_TD2556\_tf0002.sas7butl
sas.exe            pid: 2556   INTERNAL\sbass            1090: C:\DOCUME~1\sbass\LOCALS~1\Temp\SAS Temporary Files\_TD2556\_tf0009.sas7butl
sas.exe            pid: 2556   INTERNAL\sbass            10C4: C:\DOCUME~1\sbass\LOCALS~1\Temp\SAS Temporary Files\_TD2556\_tf0019.sas7butl


If I remove the path filter the command works fine from SAS.

Any ideas how to fix this issue?

Thanks,

Scott

Super User
Posts: 9,662

Quoting program name & file path argument in filename pipe on Windows

I am not sure whether it can work. But could try it.

filename foo pipe '"C:\Program Files\sysinternals.com\handle.exe" -u "%sysfunc(pathname(work))" ';

Or

%let p=%sysfunc(pathname(work));

filename foo pipe '"C:\Program Files\sysinternals.com\handle.exe" -u "&p" ';

Ksharp

PROC Star
Posts: 7,356

Quoting program name & file path argument in filename pipe on Windows

Scott,  Maybe I'm still too young to have discovered everything yet, but I've never seen a directory name, in windows, that had a file extension.  is a directory labeled sysinternals.com legal in itself?

Trusted Advisor
Posts: 1,300

Quoting program name & file path argument in filename pipe on Windows

Art, This is totally fine directory naming convention.

Give this a try...

data _null_;

  call execute('filename foo pipe "C:\Program Files\sysinternals.com\handle.exe" -u "' || "%sysfunc(pathname(work))" || '";');

run;

I do not use windows so I cannot test, but have used something similar to this previously when I did use windows.

Regular Contributor
Posts: 241

Quoting program name & file path argument in filename pipe on Windows

See if an old sas-l posting of mine helps.

Ask a Question
Discussion stats
  • 4 replies
  • 731 views
  • 0 likes
  • 5 in conversation