DATA Step, Macro, Functions and more

Replicating UNIX Commands when NOXCMD set

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

Replicating UNIX Commands when NOXCMD set

I need to be able to replicate some basic UNIX commands but work in an environment where the NOXCMD option is set and, therefore, cannot use X, call system or %sysexec in my SAS programs.

My requirement is to be able to move .XML and .txt files between UNIX directories and (potentially delete them), i.e. to replicate the mv and rm UNIX commands.  I've found several examples that use data step processing to copy files on a byte-by-byte basis so could use this as the first part of a 2 step move, but can find nothing that would delete the original source file after it had been copied. Apologies if I'm missing something obvious.  If this can't be done then I have shell scripts to do this but will have to somehow include them in my LSF Flow.

Thanks in advance.


Accepted Solutions
Solution
‎03-04-2015 06:14 AM
Super User
Posts: 5,260

Re: Replicating UNIX Commands when NOXCMD set

try the external file functions, e.g. FDELETE. haven't tried then under NOXCMD, but the documentation doesn't mention that as a constraint.

A part from that NOXCMD are typically set for a reason, you should interfere with OS level operations.

If you have a requirement for this, convince the SAS admin to let you have this restriction removed.

There is (are several?) threads in the forum on this matter, use search.

Data never sleeps

View solution in original post


All Replies
Solution
‎03-04-2015 06:14 AM
Super User
Posts: 5,260

Re: Replicating UNIX Commands when NOXCMD set

try the external file functions, e.g. FDELETE. haven't tried then under NOXCMD, but the documentation doesn't mention that as a constraint.

A part from that NOXCMD are typically set for a reason, you should interfere with OS level operations.

If you have a requirement for this, convince the SAS admin to let you have this restriction removed.

There is (are several?) threads in the forum on this matter, use search.

Data never sleeps
Super User
Posts: 6,971

Re: Replicating UNIX Commands when NOXCMD set

On any well-maintained system, I see no need for the noxcmd restriction.

Moving files is a typical OS-level activity and should be done with OS tools (and shell escapes if done from within other software, eg SAS)

Aside from that, fdelete and the other file-related functions work even under the noxcmd restriction (just tested with fdelete()); which could make for some interesting communication if the SAS admin thinks himself safe behind the -noxcmd and you manage to delete a file that SHOULD NOT BE DELETED.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Respected Advisor
Posts: 3,777

Re: Replicating UNIX Commands when NOXCMD set

Have a look a new FCOPY function, new to SAS 9.4.  It looks to be able to replace data step for file copy.  I have not used it, no 9.4 for me.

New Contributor
Posts: 3

Re: Replicating UNIX Commands when NOXCMD set

Thanks guys. FCOPY plus FDELETE does the job - apologies that I'd not picked up on these before.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 201 views
  • 6 likes
  • 4 in conversation