FTP mget * not working after change directory -cd


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FTP mget * not working after change directory -cd
# 1  
Old 06-01-2011
FTP mget * not working after change directory -cd

Hi everyone,

I have an Linux FTP script to get files from different AS400 mailboxes and store in different local directories.
I had to use mget * option becuase there is no fixed destination file name means filename can change.
The following FTP script is working fine if we have single file per mailbox (for ex:- "N0001" file in "TE.TZ.MBOX.XMIT.FPFD" mailbox) .
But if we have multiple files in mailboxes (for ex:- N0001,N0002 in"TE.TZ.MBOX.XMIT.FPFD" mailbox) the following script is not working correctly.

For example :-

if there are these two files in TE.TZ.MBOX.XMIT.FPFD mailbox
N0001
N0002

if there are these two files in TE.TZ.MBOX.XMIT.FPGD mailbox
N0003
N0004


after running the following script, Local dir "/ford/thishost/proj/batch/sonic/server/data/de/fpf" is having N0001 and N0002(good) but local dir "/ford/thishost/proj/batch/sonic/server/data/de/fpg" is still having N0001 and N0002(bad) but its not right as I am expecting N0003 and N0004.

somehow when there are multiple files in each mailbox change directory (cd) command is not working.

Could you please let me know if you have any idea how to fix this issue,

Many thanks in advance.


FTP script is :-

ftp -n <<_LABEL
open ftp.sun.com
user $USERID $PSSWRD
has
cd 'TE.TZ.MBOX.XMIT.FPFD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/fpf
mget *
has
cd 'TE.TZ.MBOX.XMIT.FPGD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/fpg
mget *
has
cd 'TE.TZ.MBOX.XMIT.FPAD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/fpa
mget *
has
cd 'TE.TZ.MBOX.XMIT.ASVD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/asv
mget *
has
cd 'TE.TZ.MBOX.XMIT.RVGD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/rvg
mget *
has
cd 'TE.TZ.MBOX.XMIT.FPVD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/fpv
mget *
has
cd 'TE.TZ.MBOX.XMIT.ASGD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/asg
mget *
has
cd 'TE.TZ.MBOX.XMIT.AFGD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/afg
mget *
has
cd 'TE.TZ.MBOX.XMIT.ASFD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/asf
mget *
has
cd 'TE.TZ.MBOX.XMIT.FPPD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/fpp
mget *
has
cd 'TE.TZ.MBOX.XMIT.VMGD'
lcd /ford/thishost/proj/batch/sonic/server/data/de/vmg
mget *
close
bye
# 2  
Old 06-01-2011
Is 'has' 'hash', and why toggle it so often?

When you cd, you are asking for a subdirectory unless you cd /topdir.
# 3  
Old 06-01-2011
The script is working fine if we have single file in one mailbox (ie one directory) , if we have only mutliple files in the mailbox then only the problem. any ideas please.
# 4  
Old 06-01-2011
Does it work if you have a session per directory?

Still seems like you need to cd to ../'TE.TZ.MBOX.XMIT.FPGD'
# 5  
Old 06-01-2011
Quote:
Originally Posted by oravikiran
The script is working fine if we have single file in one mailbox (ie one directory) , if we have only mutliple files in the mailbox then only the problem. any ideas please.
Let me rephrase what DGpickett's saying.

When you do cd 'TE.TZ.MBOX.XMIT.FPFD' your current directory changes from /current/path/ to /current/path/TE.TZ.MBOX.XMIT.FPFD/. You download those files and it goes fine.

Next you do cd 'TE.TZ.MBOX.XMIT.FPGD' which tries to change the dir from /current/path/TE.TZ.MBOX.XMIT.FPFD/ into /current/path/TE.TZ.MBOX.XMIT.FPFD/TE.TZ.MBOX.XMIT.FPGD which of course doesn't exist.

You have to cd '../TE.TZ.MBOX.XMIT.FPGD' to tell it to go up one dir.
# 6  
Old 06-01-2011
for ftp scripting I have always found lftp to be easier and better. Take a look at it as it looks like it has what you need.
This User Gave Thanks to sixstrings For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mget with SFTP is not working

hi Team, I am connecting from one (A) linux server to another(C)/any linux server by sftp on A linux server: sftp userid@C password: mget is Not working fine I am using mget to pull the files. it shows mget as invalid command. But from (B) Linux server to (C) /to Any server Linux... (15 Replies)
Discussion started by: johnsnow
15 Replies

2. Shell Programming and Scripting

Change directory with wildcard in FTP server

Hi , I am looking for a command to change directory in FTP server with wildcard specified. Basically this is what i am trying. localserver# ftp remoteserver ftp> ls 41000_42000 42000_43000 ftp> cd 41* 550 CWD failed. '41*' : no such file or directory. Could anyone please let me know... (6 Replies)
Discussion started by: thavamaniraja
6 Replies

3. Shell Programming and Scripting

problem with ftp mget

Hi I am trying to ftp all the files from a directory in server2 to server1 (both unix) The below code is in server1 ftpfile=/home/anitha/ftptxt echo cd mydir >>$ftpfile echo mget *.* >>$ftpfile cat $ftpfile | ftp -i server2 mydir is a directory in server2 and there are some test files in... (4 Replies)
Discussion started by: anijan
4 Replies

4. AIX

ftp mget directory

Hi, I have searched everywhere for an answer to this question but couldn't find one so I ask it here. From an AIX 5.3 machine I ftp to another AIX 5.3 server. I want to get all files and only files in a directory. This directory has a subdirectory with files in it. In ftp, I enter the... (5 Replies)
Discussion started by: bheinsius
5 Replies

5. Shell Programming and Scripting

Ftp-mget

For the below mentioned code..Files are getting transferred from first mget statement alone ie from /home/Arun/*EF01/...Could someone help me regarding this ftp -vn <<EOD >$LOG open user lcd ascii mget /home/Arun/*EF01/GLHEC* mget /home/Arun/*EF03/GLHEC* mget... (3 Replies)
Discussion started by: infernalhell
3 Replies

6. Shell Programming and Scripting

mget ftp command options

Hi, I am using mget ftp command to pull a bunch of zip files from Windows to local unix machines. It is working fine as follows. -rw------- 1 autosys autosys 614 Aug 19 13:13 02034128.zip -rw------- 1 autosys autosys 1866 Aug 19 13:13 02034127.zip -rw------- 1 autosys ... (1 Reply)
Discussion started by: spatra
1 Replies

7. UNIX for Dummies Questions & Answers

How to change current working directory for dbx on UNIX?

How to change current working directory for dbx on UNIX? means I'll run pgm from one directory , but getcwd() should return path which I want to be, which is not d current dir :) (5 Replies)
Discussion started by: login0001
5 Replies

8. UNIX for Dummies Questions & Answers

Change to a new working directory...

I need to CD to a particular directory to check log files and interface files. Instead of typing the path manually, is there a way of getting a script to change my working directory to the one I need? Currently I have a script that CD's to the directories I need but a soon as the script exits,... (5 Replies)
Discussion started by: jagannatha
5 Replies

9. UNIX for Dummies Questions & Answers

mget (ftp command)

hey, I was wondering if its possible to use a complete path and file name using the mget command example mget /dir1/dir2/dir3/file.ext or get /dir1/dir2/dir3/file.ext because whenever i try its says file not found or permission denied..... but if i do cd dir1 cd dir2 cd dir3 mget... (2 Replies)
Discussion started by: Ganondorf
2 Replies
Login or Register to Ask a Question