FTP File download


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP File download
# 1  
Old 10-16-2013
Signal FTP File download

Hi,

I have few files at FTP location and have written a script to download the same from ftp based on the sysdate - 1, however with the below code I am unable to download the files from FTP.

Code:
x=`TZ=CST+24 date +%Y%m%d`
mget Daily_BIH_$x_NEW.tar.gz

can anyone please help me in resolving the issue.

Regards,
Ram
# 2  
Old 10-16-2013
I think you may need to share a little more of your code first. Are you trying to set the value inside of your FTP? If not, how are you then using mget

Try to narrow it down to as small a working/failing section as possible and give us a dir listing of the file you are after on the remote server.


As a first stab in the dark though, it may be as simple as enclosing x in braces, i.e.
Code:
mget Daily_BIH_${x}_NEW.tar.gz

The way you have it, it will try to evaluate the file name as Daily_BIH_ followed by the value of $x_NEW then the literal string .tar.gz
It will likely evaluate all this to:-
Code:
mget Daily_BIH_.tar.gz

......because $x_NEW is not set.
# 3  
Old 10-16-2013
Yes. Please show code. Are you using a here document?
# 4  
Old 10-17-2013
Hi,

Herere is below the code I have written for downloading the files from FTP location:
Code:
x=`TZ=CST+24 date +%Y%m%d`
host='FTP IP Address'
user='user name'
pass='passcode'
echo "ftpinnnnggg to $host....."
a=`ftp -v -n -i << !
open $host
user  "$user" $pass
#prompt off
cd root/reports/BH
x=`TZ=CST+24 date +%Y%m%d`
mget Daily_BIH_$x_NEW.tar.gz
bye
!`

# 5  
Old 10-17-2013
Nesting back tics may give you problem. Change from `code` to $(code)
Code:
x=$(TZ=CST+24 date +%Y%m%d)
host='FTP IP Address'
user='user name'
pass='passcode'
echo "ftpinnnnggg to $host....."
a=$(ftp -v -n -i << !
open $host
user  "$user" $pass
#prompt off
cd root/reports/BH
x=$(TZ=CST+24 date +%Y%m%d)
mget Daily_BIH_$x_NEW.tar.gz
bye
!)

# 6  
Old 10-17-2013
Hi,

I have followed the same as suggested, however getting error as below, couldn't be able to uderstand.

Code:
warning: here-document at line 15 delimited by end-of-file (wanted `!')

Please help.
# 7  
Old 10-17-2013
Do you have any whitespace before the !)? If so, remove it.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unable to Download File from FTP

Hi, I am trying to download files from FTP using below FTP code. x=$(TZ=CST date +%Y%m%d) host='xxx.xx.xxx.xxx' user='userX' pass='Password' echo "Connecting to FTP Host -- $host....." echo $x a=$(ftp -v -n -i << ! open $host user "$user" $pass cd /rose/yellow/ mget... (6 Replies)
Discussion started by: rramkrishnas
6 Replies

2. Shell Programming and Scripting

Update/Download file from FTP server to UNIX Server

HI Guys, I want to download files from FTP Server to my Unix server. I have tried , buy No Luck . Below Command i have tried. 1-Wget - Error "wget' not found" 2.ftp -n $HOST ...Not Working. 3.scp -i ftp://user:passowrd@hostname:21/ran/on/test.txt Any Suggestion (2 Replies)
Discussion started by: pareshkp
2 Replies

3. Shell Programming and Scripting

Read latest file name with a date and time and then download from FTP

Hi All, Please help. I have requirement to read the file / folder based on the latest date and download the file and folder. There will be files and folders in the location like 20140630-144422 20140630-144422.csv 20140707-182653 20140707-182653.csv 20140710-183153... (7 Replies)
Discussion started by: Praveen Pandit
7 Replies

4. Shell Programming and Scripting

Wanted to download the yesterday's file through FTP

Hello, Wanted to download the yesturday's or current date-1 file through shell script Mode: FTP OS: AIX if today is 13th May then file would be available as below. File Pattern:201401148682_daily_2014-05-12.txt.zip Help.. (4 Replies)
Discussion started by: Riverstone
4 Replies

5. Shell Programming and Scripting

Download latest file via ftp server unix through shell script

Hello this is my first post in this forum , I dont want to be unhappy.. I am writing one script but facing difficulty to find the latest file with some new pattern My requirement is 1. The file is coming like "ABCD-23220140303" at FTP server once in a week. 2. script will run on daily... (3 Replies)
Discussion started by: ajju
3 Replies

6. UNIX for Advanced & Expert Users

Want to download a latest file with current date from FTP location

Dear Friends, I need help to write a shell / perl script to download the files from FTP location, having different file names (date inside the file name). Example: Mar 5 09:24 cfx_03052013_return_file.txt Mar 6 02:13 cfx_03062013_return_file.txt Mar 7 06:40... (3 Replies)
Discussion started by: Praveen Pandit
3 Replies

7. Shell Programming and Scripting

Question about how to ftp download the latest file from a directory

Dear all, Hope you are doing well. I am in trouble to write a shell for ftp downloading the latest file from remote server. Situation: There is a directory named 'weekly' which contains .csv files with the following pattern: RES_EN_100417-080003.csv.Z. The new file is generated... (3 Replies)
Discussion started by: kel1014
3 Replies

8. Shell Programming and Scripting

How to download X bytes from a file using ftp or http?

Hi, I have a simple ftp shell script which can download the entire file, however I want to know if there is anyway that I can download only the partial content, say X bytes from a file. If so, how I can do it using ftp and http.. Here is my sample script #!/bin/sh HOST='xyz.com' ... (5 Replies)
Discussion started by: learn more
5 Replies

9. Shell Programming and Scripting

download specified file from ftp server

Hi all, I'm having problems downloading files from ftp server. I have to download only those files that name starts with YYYYMMDD.But file comes like the format "20080624221035.TXT".Also how i can get list of all file names with in specified folder. Here i paste my code ftp -vn... (1 Reply)
Discussion started by: vaskarbasak
1 Replies

10. Solaris

Urgent...FTP unable finish download file, hang half way

Hi all, I have 1 problem in my solaris 8 server. The problem is in every nite that will run a cron job to download file from external ftb server. This crob job starter running find, but after running for 4 minute, that ftp services is hang that, until we need kill this process. My question... (3 Replies)
Discussion started by: foongkt5220
3 Replies
Login or Register to Ask a Question