How to use a variable in FTP?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to use a variable in FTP?
# 1  
Old 05-06-2005
How to use a variable in FTP?

My problem is that I want to FTP some files to a remote machine. However, the user will supply the remote machine directory name during runtime.

I wrote following script, but it can't resolve $AI_DH_FTP variable name inside FTP. It works fine if I specify a hardcoded path (as shown in the just above line)

Any help? Thanks in advance.

ftp tb135
prompt
cd /ftpshr/data/DNHMBY_OUT/dev/
#cd $AI_DH_FTP
mput cm_customer_dhout*.dat
prompt
bye
echo "Completed FTP to remote machine."
# 2  
Old 05-06-2005
you've fogotten [???] the here-doc AND the user/password for logging in [unless you have .netrc set up appropriately]:
Code:
ftp -n tb135 <<EOF
   user hereMyUser hereMyPasswd
   prompt
   cd /ftpshr/data/DNHMBY_OUT/dev/
   cd $AI_DH_FTP
   mput cm_customer_dhout*.dat
   prompt
   bye
EOF


Last edited by vgersh99; 05-06-2005 at 11:16 AM..
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to redirect output of a command to a variable during ftp mode?

Hi, How can I redirect the output of a following command to a variable. ftp myservername ftp> user (username) guptaji 331 Password required for guptaji. Password: ftp> size /home/salil/abc.dat ftp> a='size /home/salil/abc.dat' ?Invalid command I want to redirect value of size to... (1 Reply)
Discussion started by: Salil Gupta
1 Replies

2. Shell Programming and Scripting

FTP script variable issue

Hi , I have a following code ,I need to send two files on FTP server using single code UDL_FTIHOST_1=podftiapp02.com UDL_FTIUSER_1=dbsunny UDL_FTIPWD_1=sunny@11 UDL_FTIHOST_2=podftiapp01.com UDL_FTIUSER_2=dbamy UDL_FTIPWD_2=amy@12 count=2 i=1 while do FTIHOST=$(echo... (3 Replies)
Discussion started by: sonu_pal
3 Replies

3. HP-UX

[Solved] Unable to rename file in ftp server .Net:FTP perl

Hello All, I am trying to connect to ftp server and get the files. Also i need to rename the file in other ftp dir. rename method is not allowing me to rename the file in other dir. When i tried copy command by using net::FTP:FILE then perl says it is not installed. Can some body help me to... (2 Replies)
Discussion started by: krsnadasa
2 Replies

4. UNIX for Dummies Questions & Answers

retreiving file name in a variable on ftp

Hi , I need to retreive the file name in an variable on the ftp server.Can you guy please let me know how can i do that.I need some thing like connect to ftp <<eof new_variable=`ls *_1_AUDIT.txt *_2_AUDIT.txt` (but on a ftp server) mget $new_variable >>eof (1 Reply)
Discussion started by: Param0073
1 Replies

5. UNIX for Dummies Questions & Answers

Help with FTP Variable Transfer

Hey all, I'm trying to upload a file to my ftp server through an automated batch program. I will be uploading a file that's name changes according to you IP Address, so I am using the variable %ip% to represent the file's name. The problem occurs when it transfers over to the ftp portion of the... (2 Replies)
Discussion started by: piking
2 Replies

6. Shell Programming and Scripting

How to pass variable to ftp script?

how can I use shell variable inside ftp script as in below:- the case as below:- I have folder names as (Sunday,Monday...etc) and inside these folders I am trying to get files where their names are "mf_usm_ssnc*_mo0'HOUR''MIN'". where HOUR= hour as in `date "+%H"` - 2 MIN= either... (2 Replies)
Discussion started by: ahmad.diab
2 Replies

7. Shell Programming and Scripting

using a variable within ftp shell script

hi all i have a problem. i have a file called 20091015_extract.csv in my shell script i set the following variable: TODAY=`date +%Y%m%d` when i start an ftp session (within my shell script) I want to transfer the file like this: put $TODAY_extract.csv however, ftp is not... (2 Replies)
Discussion started by: soliberus
2 Replies

8. UNIX for Advanced & Expert Users

Using FTP to check whether file is completely FTP... plz find the description below

Hi, We have some clients who will place huge files in to one of the remote server. And the shell script written in our local server to retrieve client files (using FTP) placed on one of the remote server of ours by clients. My question Is there any FTP command/script to check from my local... (1 Reply)
Discussion started by: nmsrao
1 Replies

9. UNIX for Dummies Questions & Answers

Automated FTP to variable directory with error check

Hi, automated FTP that have error check and each product FTP will used the same userid/password to post(transfer) the file(s) from their <product> directory at UNIX to their <product> folder at Windows. such senarios as follows: NOTE: ======= ** Variable ** * The <product> is variable... (3 Replies)
Discussion started by: songtam
3 Replies

10. UNIX for Dummies Questions & Answers

passing ip address as a variable to script for ftp

Still a Beginner here .. Does anyone no how to get the IP address of the machine thats logged in (bearing in mind there will be others logged in) while they are logged in to the Unix server and pass this as a variable to a shell script so as I can FTP files to that machine via a shell script, at... (2 Replies)
Discussion started by: Gerry405
2 Replies
Login or Register to Ask a Question