BookmarkSubscribeRSS Feed
TesterSK
Fluorite | Level 6

Hi,

 

I have an issue when I try to connect to a sftp server in SAS. I can connect to the sftp server in Linux without problems doing this:

 

 

su test
/*insert pass*/
cd /xxxx/sas/tmp/fort/files
sftp -oIdentityFile=/home/xxxx/.ssh/key_sftp xxxx_sftp@servergin01.western.world:/dpor/port/high/KBV
put /xxxx/sas/tmp/fort/files/google_01.html
put /xxxx/sas/tmp/fort/files/gwrwe_02.png
exit

 

But If I execute this I can't see the new files:

 

 

x "su test";
x "/*insert pass*/";
x "cd /xxxx/sas/tmp/fort/files"; x "sftp -oIdentityFile=/home/xxxx/.ssh/key_sftp xxxx_sftp@servergin01.western.world:/dpor/port/high/KBV"; x "put /xxxx/sas/tmp/fort/files/google_01.html"; x "put /xxxx/sas/tmp/fort/files/google_01.png"; x "exit";

 

I tried to execute a mv command with SAS and works fine. Maybe SAS can't connect to the server?...

 

Regards.

 

3 REPLIES 3
Tom
Super User Tom
Super User

You cannot do it that way.  (You might not be able to do it at all if it requires you to pretend to be a live person and type a password).  Each X command is going to run in another unix shell instance. So the 'put" statement is not going to work because the new shell where it is running does not have the sftp command running.

 

Create a shell script and use the X command to run the shell script.

Use scp instead of sftp.  Use a separate scp command to copy each file.  Then you are running just one the self contained command.

If you really must use sudo to have access to read the files you want to transfer then I think you will have a big problem.  And if you don't need it then why did you include it?

TesterSK
Fluorite | Level 6
Hi Tom,

I tried to do that with FILENAME SFTP but I couldn't connect, that's why I tried that.

In one line command have the same issue.

SAS Documentation just make connections for read a file. Do you know how should I do this with FILENAME? (If is more easy than using x command or a script)...

Regards.
ChrisNZ
Tourmaline | Level 20

Read @Tom 's reply again. There's no mention of a filename.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 3 replies
  • 1351 views
  • 1 like
  • 3 in conversation