- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
We have a lot of command X in our programs such as Rmdir, del, Dir ... Etc.
The problem is that one X command had delete all files, when '&path' macro-variable was empty :
X " rmdir /Q /S &path";
My question here : What the best programming way that you recommended to deal with this case :
+ Check Macro-variable before the X command .eg : check if '&path' is empty path ?
+ Any alternative to the famous '\Q \S', we can change it by something else or avoid it laterally ?
How to safe our data from this monster of " rmdir \q \s" ?
Another question : I identify those command X : "Del, move, copy " to be also less danger than rmdir, can you mention other command x that probably can be danger ?
I wait your entitlement Dear SAS expert 🙂
P.S : i'm simple developer not admin.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
"What the best programming way that you recommended to deal with this case" - Quite simply don't use SAS to system admin tasks. There is far better software out there for this type of task, and having a proper admin process in place to create/remove areas, and using version control systems is always the better (if not best) method to achieve this. Writing some code yourself is going to be lots of work, and likely to break each run opening you up to the danger of deleting whole hard drives.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@RW9: we have version control systems so the data is always safe, but need some days to be recover. the purpose is just run x cmd safetly : like check if the path to be deleted exsite and not emplty. some tips like that assure more the command X.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
There is no "safely" with X command, it just passes text out to the operating system. Its why a lot of places disable that by default. You have all the tips there, does the path exist (which will also check missing or not).
But if you have version control systems in place then you should not need to remove anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I would recommend creating your own programs to do the actions that you need done. You can then test these program to make sure they take proper action in all cases. Then only use your tested programs in your code rather than running any X (system, pipe, etc) command directly in user written code.
For SAS that would probably be done by creating a macro or macro library.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@Tom That what are doing now. but , accidentally : an empty &path , in rmdir had delete all file !! 😕 i
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@amager wrote:
@Tom That what are doing now. but , accidentally : an empty &path , in rmdir had delete all file !! 😕 i
Then update your test suite for that macro and include a test for that case!!
I have a step in a macro that allows users to remove a project directory. It will only run if the directory is empty. So it firsts gets a list of all of the files in the directory and checks that it is empty (or only includes some specific filenames that we don't care about). If it is not empty it fails and reports the problem to the log.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Indeed, we did it already.
Also, I suggested to run a macro that search for cmd X in programs, to be checked before validation :
filename cmd pipe "findstr /s /n /i /p /r /b ""[xX] .rd|del"" ""&server_sas"" ";
what you think by the way about this regrex expression : "[xX] .rd|del", can find 'rd' and 'del' cmd x ?
P.S : I know findstr not match prefectly with regrex but no choice.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content