Sunday, April 26, 2009

Shell script for File Movement between Servers

From very long i used to get a common requirement that some system will place the files in a server.
the system should get the files and process them
for achieving this we need to have shell script which will connect to the server and ftp the files to the source server..
Plz find the sample script for doing this..
after writing the script we have to schedule the script in unix using a cronjob...

--Shell script starting
#! /usr/bin/ksh
HOST=egltest.test.co.in
USER=applprod
PASSWD=applprod

chmod -R 777 /egltestarch1/oracle/EGLTEST/test/coa/*.txt

exec 4>&1
ftp -nv >&4 2>&4 |&

print -p open $HOST
print -p user $USER $PASSWD
print -p bin
print -p lcd /egltestarch1/oracle/EGLTEST/test/coa
print -p cd /egltestapps1/home/test/coa
print -p mget *.txt
print -p bye

exit 0
--Shell script ending name it as ftpcode.sh

this shell script is saved in /egltestarch1/oracle/EGLTEST/dba/sh/ftpcode.sh
After writing the script we need to a cronjon entry..this entry will run the script on the schedule we have given..

for this
crontab -e
using vi editior commands to make this entry below..this will run the script every minute and log is the written to the file specified on the right side...



# ftp files from application server to database server
* * * * * /eglprodarch1/oracle/EGLPROD/dba/sh/ftpcode.sh > /egltestarch1/oracle/EGLtest/dba/log/ftpcode.log 2>&1

once the files are dowloaded make sure to delete or move to other folders to automate the FTP process...

5 comments:

Unknown said...

Hi Murthy,
I am into Oracle apps-AR module project.. In our proj, we receive a file from another team(Risk team..interface not set up)
fortnightly (two on each intance..there r 3 instances).
This file is FTPed on our production instances (unix)and we manually process it by running an inbound program that populates the records into an interim table.
I wanted to automate this.I have read about in unix's netrc file that shares login information in a secure mode n helps in connecting to a remote pc..How can I make this work in given scenario, provided we dont want to use crontab?do both the teams have to share their login credentials ( apps id n pwd).What changes will be reqd. on their side and if rexec command wud be of help.Lastly, how will I make the concurrent inbound program run once the file is ftp'ed on our box?
Please help with a step by step procedure for this.Your help will be truly regarded.

Donovan said...

What is exactly shell script? What is it used for? I need more information about it because I am a beginner in computer field.

Unknown said...
This comment has been removed by the author.
Unknown said...
This comment has been removed by the author.
Unknown said...


Regards
Sridevi Koduru (Senior Oracle Apps Trainer Oracleappstechnical.com)
LinkedIn profile - https://in.linkedin.com/in/sridevi-koduru-9b876a8b
Please Contact for One to One Online Training on Oracle Apps Technical, Financials, SCM, SQL, PL/SQL, D2K at sridevikoduru@oracleappstechnical.com | +91 - 9581017828.