BookmarkSubscribeRSS Feed
ScottBass
Rhodochrosite | Level 12

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


Please post your question as a self-contained data step in the form of "have" (source) and "want" (desired results).
I won't contribute to your post if I can't cut-and-paste your syntactically correct code into SAS.
4 REPLIES 4
Ksharp
Super User

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

art297
Opal | Level 21

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?

FriedEgg
SAS Employee

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.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 1772 views
  • 0 likes
  • 5 in conversation