BookmarkSubscribeRSS Feed
Mada1
Fluorite | Level 6

Hello,

 

System: 9.4 on Windows

 

Has anybody managed to use SAS to work with Stunnel? 

I am trying to "convert" the sh script below to run from SAS so that I can transfer files using the stunnel. The stunnel is already set up and the sh script below is working.

user@server filedump$ sshpass -f "/folder/subfolder/passwordfile" scp -P 2222 -oKexAlgorithms=+diffie-hellman-group1-sha1 -oMACs=+hmac-sha1 -c aes128-cbc -p user@localhost:/folder/subfolder1/file.txt /home/users/folder/subfolder/
 
I would like to confirm that no private keys have been used.
 
I have tried to use SAS filename ftp but it failed. I don't know if and where we can use +diffie-hellman-group1-sha1 and  +hmac-sha1
I have also tried to configure SAS filename socket but so far is not working. 
 
Thank you for your help.
 
Regards,
Madalin
 
 

     

5 REPLIES 5
ballardw
Super User

Can you use the X or XCMD statements in your current configuration? That allows passing commands to the operating system just like typing them on a command line.

 

Your configuration may have XCMD disabled though.

 

There is also CALL SYSTEM routine that can call system commands from a data step.

Mada1
Fluorite | Level 6

Hi,

 

Thank you so much for your answer. 

I know I can use the x cmd which would probably work ok in the dev environment but in prod environment x cmd are disabled. This is the reason why I tried filename ftp and socket. 

 

Thank you,

Mada1 

ballardw
Super User

Often the CALL SYSTEM or SYSTEM statements aren't disabled when XCMD is.

 

I haven't a clue about stunnel or any of that side, just trying the fixes with basic SAS approaches to external programs.

 

You might try sharing some of your Filename experiments showing the log with any messages. I know the filename can take a lot of options but where something like this may fit I have no clue.

Mada1
Fluorite | Level 6
Hi,
Using filename ftp I have tried the following. The intention was to copy the dataset stpsale between the two servers.

filename indir ftp '/home/users/myfolder/Mada' DIR
host="server_name"
user="user"
pass='password';


filename outdir ftp ' ' DIR FILEEXT
host="1.11.111.1"
port=2222
user='user2'
pass='password2';

data _null_;
infile indir(stpsale) truncover;
input;
file outdir(stpsale);
put _infile_;
run;

The code above returns error on both indir and outdir.

The test using filename socket below show that the port 2222 is already used (because the Stunnel is running on localhost on port 2222) but I didn't know how to continue from this point

filename local socket ':2222' server;
data tcpip;
infile local eov=v;
input x $10;
if v=1 then
do;
put 'new connection received';
end;
output;
run;

At the moment call system below returns the error "ERROR: Shell escape is not valid in this SAS session." (but I'm running on SAS EG and I think changes are required in SAS MC to solve this error)

data _null_;
call system('dir /w');
run;

Thank you for your help.
Regards,
Mada


ilyak
Calcite | Level 5
Hi,
Try filename pipe
FILENAME fileref PIPE 'operating-system-command' option-list;

https://blogs.sas.com/content/sgf/2016/03/11/using-a-pipe-to-return-the-output-of-an-operating-syste...

Best Regards,
Ilya

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1566 views
  • 1 like
  • 3 in conversation