BookmarkSubscribeRSS Feed
sudharsanan
Calcite | Level 5

Hi,

I read from websites that having "2>Nul" in the end of cmd statement will route stderr output in windows. This works for me in below statement.

filename dirinfo pipe 'dir &path 2> Nul';

But it does not work in SCL system function with xcopy cmd statement. For eg. rc=system('xcopy <filename> <target folder> 2> Nul');

After I added 2>Nul in the end of the statement, return code rc is 4 and copy is not happening (usually on successful copy rc was 0).

Do you have any suggesstion to route stderr output from cmd statements in system function?

Thanks in advance!

-Sudharsanan

5 REPLIES 5
jakarman
Barite | Level 11

AF/SCL is behaving different I some aspects.  It will build a buffer that is processed by Scl before it is given to the sas-processor.

You did not post your excact coding. When your are using SAS(R) Component Language 9.4: Reference, Second Edition (scl function) . 
xcopy itself should work as you described. Sure the statement that is generated is correct? No other changes? 

---->-- ja karman --<-----
sudharsanan
Calcite | Level 5

Thanks for your reply.

I have not done any other change than adding "2>nul" to the end of of the xcopy statement.

The code I had was working rc=system('xcopy <filename> <target folder> '); by copying files and rc=0.

When I changed it as rc=system('xcopy <filename> <target folder> 2>nul '); it was not working and rc=4.

jakarman
Barite | Level 11

Well <filename>  and <target folder> are for sure not the real values, something is changing that.

If that something is doing a parse and change the < > characters than that something can also change your 2> null.   

---->-- ja karman --<-----
sudharsanan
Calcite | Level 5

Hi Karman,

Thanks.

I have variable for <filename> and <target folder>. They have quotes and it was working without "2>nul" added in the end of the statment.

I have tested in many different cmd statement that having "2>nul" in SCL System function does not work.

The same issue happens in SAS/Base System function also.

For me "2>nul" works only in pipe statement with dir cmd command.

Please let me know if any suggestion.

jakarman
Barite | Level 11

For the SAS/Base language I know the issues well  with all quutin issues

SAS(R) 9.4 Macro Language: Reference See the different meanings of special chars. Al lot of work when they are involved and needing bypasses. The difference between single and double quotes for strings can be very important. There is somewhere interference of symbols

You did not show the command (put statement) in full glory or other debugging action.

The usage of this as SCL function or as modified (submit block) SAS-base processing I am also not seeing... 

The SAS-base is probably easier to debug focus on the quoting remarks.

---->-- ja karman --<-----

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
  • 5 replies
  • 829 views
  • 0 likes
  • 2 in conversation