![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Assigning values to an array via for/while loop | fiori_musicali | Shell Programming and Scripting | 2 | 11-24-2008 11:01 PM |
| Reading from while loop into an array | ssuresh1999 | UNIX for Dummies Questions & Answers | 2 | 08-12-2008 11:53 AM |
| Array in loop is acting up | RisingSun | Shell Programming and Scripting | 5 | 08-07-2008 02:21 PM |
| How to use array values after the loop. | Devesh5683 | Shell Programming and Scripting | 1 | 05-13-2008 07:38 PM |
| Array Declaration and For Loop | 33junaid | Shell Programming and Scripting | 4 | 09-15-2007 04:16 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
FTP and run a loop for array problem
Hello,
I have a problem with my script whereby it does not want to loop. The function of my script is to FTP into a server and go to each directory/volume in the array 'VOL'. The way the loop is suppose to work, is to go into the first volume, get the files of R(yesterday's date) and save them in another server .. 'REPOSITORY' and then move on to the other volume in the array. The problem with my script is that it does not loop. It just runs in the first directory then ends. Code:
if [ $# -ne 1 ]
then
DAISAGO=1
else
DAISAGO=$1
fi
YESTERDAY=`date -d ${DAISAGO}day+ago +%y%m%d`
REPOSITORY=/home/CDR-backups
cd $REPOSITORY
VOL=(D010AMAB D000AMAA D010AMA9 D000AMA8 D010AMA5 D000AMA6 D010AMA7 D000AMA4 D010AMA3 D000AMA2 D010AMA1 D000AMA0)
ftp -n ##.##.##.## << !EOF
user ****** ******
binary
lcd $REPOSITORY
for VOL in ${VOL[@]}
do
cd /$VOL
pwd
dir
mget R${YESTERDAY}*
done
bye
CDR:/home # ./getama.sh Connected to ##.##.##.## 220 Welcome to Bla Bla Bla 331 Password required. 230 User logged in, proceed Remote system type is SOS. 200 Command okay. Local directory now /home/CDR-backups usage: for format ?Invalid command. 200 Directory changed. 257 Current working directory is "/D010AMAB" 500 Syntax error, command unrecognized. 227 Entering Passive Mode (##,##,##,##,11,186) 150 File status okay; about to open data connection. DIRP_FILESEG FIXED 2048 ******** DIRP_FILESEG FIXED 2048 ******** DIRP_FILESEG FIXED 2048 ******** 226 Request successful. Closing data connection. ?Invalid command. 221 Service closing control connection. Can someone please help me. Please and thanks. |
|
||||
|
ftp is NOT a scripting language. You could create a string (script) using your loop logic from the shell and pass the resulting created script string as input to ftp.
Your version of ftp client might not like a large set of commands coming at it using the mechanism you are using though. Try it. |
|
||||
|
I'm sorry, I don't quite understand. This is the first time I'm writing a shell script and I've been following some tutorials. Are you saying that I can't run a For Loop while being in an ftp session?
Also ... I'm not familiar with string (script). I tried googling it but I can't come across anything useful. Can you direct me to tutorials? I would really appreciate it. thanks. Last edited by tuffgong2008; 12-19-2008 at 03:44 PM.. Reason: Adding more info |
|
||||
|
Yes that is what he is saying, you can only run basic FTP commands while in the FTP session.
There are plenty of articles around on passing a script as input to ftp, here is one I found on this forum: http://www.unix.com/shell-programming-scripting/24522-loops-within-ftp-shell-session.html Hope this helps ![]() Last edited by ronnie_uk; 12-19-2008 at 05:22 PM.. |
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix commands, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|