BookmarkSubscribeRSS Feed
Albert0
Quartz | Level 8

Hi All, 

 

I'd like to ask your help regarding on converting the ftp code in a .sh file below to a code that can run in SAS BASE?

 

#!/bin/bash

 

WINDOWS_SERVER=sasftp001

USER=sasdemo

PASSWORD=abc123

 

ftp -in <<EOF

open $WINDOWS_SERVER

user $USER $PASSWORD

ascii

lcd /sas/sasdata/data/myfolder

put test.txt

cd /WindowsFolder/App/Data

close 

EOF

 

 

The code above is working fine. Can everybody help me translate this one to a sas code? I created an ftp code but its not working so i tried creating the above script. Below is my SAS code :

 

filename src ftp 'linux path' host='abc.com.' binary dir

                               user = 'sasdemo' pass= "abc123";

filename tgt ftp 'windows path' host='sasftp001' binary dir user='sasdemo' pass= "abc123;

 

data _null_;

infile src(test.txt) truncover;

input;

file target(test.text);

put _infile_;

run;

 

 

Thanks, 

Albert0

 

 

 

 

1 REPLY 1
Kurt_Bremser
Super User

Is SAS running on one of the involved servers? This would allow a simpler filename statement for either source or target.

 

When reading/writing text files, avoid the binary option, and use the complete absolute pathnames in the filename statements:

filename src ftp
  "/linux path/test.txt"
  host='abc.com'
  user = 'sasdemo'
  pass= "abc123"
;

filename tgt ftp
  "windows path\test.txt"
  host='sasftp001'
  user='sasdemo'
  pass= "abc123"
;

data _null_;
infile src;
file tgt;
input;
put _infile_;
run;

Post your log for steps that do not work.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 1 reply
  • 1144 views
  • 0 likes
  • 2 in conversation