I am trying to accomplish a simple task using SAS & Unix server-
i) Create a shell script in a particular Unix directory which will have FTP commands
ii) Run this shell script from SAS to transfer the required files from server1 to server2.
Step i) is easily done using a data step+file statement+ put statements.
Stepii) is not working and I have tried 3 different ways -
a) X command
X 'sh /SASInt/.../ftp_script.sh &';
b) %macro sample;
%sysexec %str(sh /SASInt/.../ftp_script.sh &)'
c) filename results pipe "sh /SASInt/.../ftp_script.ksh &";
Even if I change the permissions to 777 for ftp_script.sh, it does not work.
I will reply to your questions -
1. It does not throw any errors. The log file shows it as executed but I dont see the file being transferred from server1 to server2. So, that means the ftp commands inside the shell script have not worked.
2.yes. I can execute this shell script from my unix command line. It works perfect.
3.I believe korn shell is the default shell. We also have bourne shell but I think the shell need not be changed?
The final objective is to move text file/raw files from server1 to server2 where our group's SAS tools/instances are installed.
I think abdullala is on the right track. You gave the complete pathname of the script you wish to run; so, it runs. However, the working directory of the shell is the working directory SAS uses.
If the SAS working directory in not your home directory, and if the ftp commands in your script file do not give the complete pathnames of the files you wish to transfer, then the ftp process will not find the files. However, when you ran the script from the command line the current working directory was your home directory; hence, the files were found and the script succeeded.
1) put the complete pathnames of the files into your script.
2) put a cd command to your home directory (cd ~) into your SAS X command.