Monday, February 17, 2014

How to use variable in GET command of FTP shell scripting ?

www.unixbabuforum.inI have assigned a value to the variable, then use the variable in GET command of FTP as remote-file . The below code is not working . Can anyone help me out. 

#!/bin/bash 
set -x 

FTP_FILE_NAME = "file1.txt" 

echo "Before ftp" 

#ftp FTP_FILE_NAME file from hmsdalfile to NewDir 
ftp -n ftpHost<<SCRIPT 
quote USER "User" 
quote PASS "Pasd" 
pwd 
binary 
cd /med/files 
pwd 
lcd /home/filenames 
get $FTP_FILE_NAME "new_file.txt" 
quit 
SCRIPT 

echo "After FTP" 


www.unixbabuforum.inIn the assignment: FTP_FILE_NAME = "file1.txt" 

you are not allowed any spaces around the = 

In this form, I would have expected an error?message during the assignment like: FTP_FILE_NAME : not found
www.unixbabuforum.inIf you execute X = Y, shell assumes X is a command 


and "=" , "Y" are two distinct arguments... 

but X=Y means an assignment statement...

0 comments:

Post a Comment

 
Design by BABU | Dedicated to grandfather | welcome to BABU-UNIX-FORUM