Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FTP from Unix db2 server to another unix server

Status
Not open for further replies.

cristi22

MIS
Aug 17, 2005
155
0
0
US
Please help newbee in unix!

There is a task which runs on the DB2 via the task center:
task:
Code:
connect to ali user ali using ali;
export to   "/sanbasys/basysload/MEMBER.IXF" of IXF  select * from MEMBER; 
export to .....
connect reset;

I need to create a unix shell to:

(1) ftp MEMBER.IXF and other files to another server (masys)
(2) if ftp transfer return code = 0 then delete files from DB2 server.
(3) send e-mail with "task successful" message

someting like this:
cd bin
Code:
vi ftp_file:

#!/bin/ksh
machine masys login masys  password masys
lcd "home/BK_DIR"
put member.ixf member.ixf

if ftp=0 then
 rm member from ali
end

mail "taks is good"
rm member*

end 
good buy

THANKS A LOT FOR YOUR HELP!
 
There are a number of issues here. The first, and most serious is that ftp returns 0 on successful completion whether or not the files were actually transferred.

If at all posible I urge you to look at ssh and the associated scp and sftp. Then the script becomes very simple
Code:
#!/bin/ksh
scp /home/BK_DIR/member.ixf user@remote_host:/remote/path && rm /home/BK_DIR/member.*
Otherwise the only method I know of guaranteeing that an ftp job has completed is to ftp the file back again under a different name and compare the returned file. In pseudo code
Code:
cd /home/BK_DIR
ftp othe_host
  put member.ixf member.ixf
  get member.ixf member.test
if diff member.ixf member.test == 0
  rm member.*
ftp can be coded using HERE scripts or .netrc scripts. Both have major security issues.

Ceci n'est pas une signature
Columb Healy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top