- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
So I was wondering, can you run the following bit of code within SAS to set a file to read only mode?
x attrib r+ C:\My Work\Documents\example.doc;
or
%sysexec attrib r+ C:\My Work\Documents\example.doc;
I tried running it and it did not work, am I missing something?
Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In your first example you miss quotes:
x 'attrib r+ "C:\My Work\Documents\example.doc"';
Note the singel quotes around the whole DOS part, and the double quotes around the path - double quotes are needed as there are spaces in the path - this means the actual underlying path is not really like that as old dos does not allow spaces or long paths etc. so the UNC path needs quoting.
Although why you are doing it this way is a mystery to me? If its needs to be secure then post it to a document storage (version/access controlled) such as Sharepoint, or use the VCS on your system. Otherwise every time you want to do anything you need to unlock run re-lock, which just seems a bit pointless.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
In your first example you miss quotes:
x 'attrib r+ "C:\My Work\Documents\example.doc"';
Note the singel quotes around the whole DOS part, and the double quotes around the path - double quotes are needed as there are spaces in the path - this means the actual underlying path is not really like that as old dos does not allow spaces or long paths etc. so the UNC path needs quoting.
Although why you are doing it this way is a mystery to me? If its needs to be secure then post it to a document storage (version/access controlled) such as Sharepoint, or use the VCS on your system. Otherwise every time you want to do anything you need to unlock run re-lock, which just seems a bit pointless.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Perfect!
I agree a CVS system is far better, however I am unable to use this at this moment in time.
Quick additional question is there a way to stop the command window open and closing, I want it to run like SAS code, with no windows popping out? Because currently when it runs, the command window flashes up quickly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Sorry I explained that poorly, the NOXWAIT means it closes the prompt and I return to SAS automatically, I just want to not see the command prompt pop up at all, even for a split second, I do not want to see it (this is my OCD kicking in!)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Afraid not, if you call a shell command, it opens the command window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @craig159753,
If you issue the shell command via a pipe, the command prompt should not pop up:
filename doscmd pipe 'attrib +r "C:\My Work\Documents\example.doc"';
data _null_;
infile doscmd;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I think you command should be attrib +r instead of attrib r+
x attrib +r C:\My Work\Documents\example.doc
Even if it do not work then provide full path of attrib.exe i.e. C:\Windows\system32\attrib.exe
x C:\Windows\system32\attrib.exe +r C:\My Work\Documents\example.doc;