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.comsas.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
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
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?
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.
See if an old sas-l posting of mine helps.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.