The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




Thread: FTP automated?
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #7 (permalink)  
Old 05-18-2001
kornshellmaven kornshellmaven is offline
Registered User
  
 

Join Date: Apr 2001
Posts: 25
Lightbulb

Not sure why it's not expanding the variables within the here-document - Turn xtrace on to see commands echoed back

The following works fine
#!/usr/bin/ksh -x
DATA=$AL_DATA
ftp -n -v slapdev <<-END
user userid password
pwd
cd $DATA
pwd
END
It doesn't matter if I cd to $DATA or $AL_DATA (exported variable)- it gets expanded OK

We also have routines to build the FTP here-doc dynamically
exec 4>dynam_ftp.sh
print -u4 "#!/usr/bin/ksh -x"
print -u4 "ftp -v -n $DEST <<-END"
print -u4 "user $USER $PASSWORD"
print -u4 "cd $DATA"
print -u4 "pwd"
print -u4 "lcd $SRC_DIR"
print -u4 "mget $FILE_PATTERN"
print -u4 "END"

chmod +x dynam_ftp.sh
dynam_ftp.sh

The contents of the dynam_ftp.sh file will have the fully expanded variable values. The above might be a little overkill for your needs.

We're running Solaris 7 as well