That's not exactly what I want. You need to loop through all the dates in the in the month of December. I need to do "get" 31 times for each of the day in the month.
Main Topics
Browse All TopicsI use the "mget" command to retrieve files using wildcard:
mget az_*.txt
However, it seems that the FTP server does not allow the mget with wildcard:
permission denied (server msg: 'syserr: The file access permissions do not allow the specified action., file: az_20090723.txt')
If I use the normal "get" without wildcard, it works fine.
Therefore, to get around this problem, I am thinking of using "get" command multiple times.
Basically, the script will be run once a day, in the whole month of December.
Some other program will put a file into the FTP server in one of the day in December. For example, the program puts the file az_20091205.txt into the FTP server on 5 Dec 2009.
As my script will not know which day the file is put into the server, it must try to retrieve every day in the month of December. So every time that the script is run, it must try to retrieve files from az_20091201.txt to az_20091231.txt.
If I use the "mget" command, I can just do a "mget az_*.txt". But since it is not permitted to be used, I will need to grab files from az_20091201.txt to az_20091231.txt.
How do I write the unix scripting loop (to run on Solaris) to call "get az_20091201.txt" to "get az_20091231.txt"?
Thanks.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
ok, here a modified script
for d in 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
do
file=az_200912$d.txt
ftp remotesystem <<-END
get /path/to/$file
END
done
One more thing , you need to automate ftp login by:
For ftp to work without providing any username / password, use .netrc file in the user's home directory (the one who will run the script). This file should not be readable by others i.e. use
cd
chmod 400 .netrc
The entry in .netrc should be as below:
machine remotesystem
login remoteusername
password mypassword
remotesystem is the server which is the ftp server where you want to sent the file(s)
remoteusername is the remote user login name on the ftp server
mypassword is the password of the remote user on the ftp server
for more info about .netrc, please use man netrc
the ip address of remotesystem should be resolved by dns or be entered in /etc/hosts file
Business Accounts
Answer for Membership
by: omarfaridPosted on 2009-07-23 at 23:31:38ID: 24932589
you may run a crontab job on daily basis that will do that for you
- script to do that
file=az_`/usr/bin/date +%Y%m%d`.txt
ftp remotesystem <<END
get /path/to/$file
END
the crontab job will look like this
59 23 * 12 * /path/to/script