Skip to Content
Author's profile photo Former Member

Useful ftp script for some daily transfers.

Useful ftp script to transfer files from SAP server daily to another file server.

In my case I transferred daily audit logs from SAP ERP server to another file server.

1)Create a .netrc file under root user $HOME directory / .  There is sample netrc file under /usr/samples/tcpip/ .

Register file server IP and login credentials:

machine <IP> login <username> password <password>

/wp-content/uploads/2014/12/1_615989.png

Its rights should be 600 (rw- — —) . Otherwise we get an error like:

/wp-content/uploads/2014/12/2_615990.png

chmod 600 .netrc

Then we can immediatley login to file server (which we’ll transfer our audit files to).

2)Here is the little script /tmp/FtpDailyAudit.sh :

#!/bin/ksh

#Calculating YESTERDAY variable value

YESTERDAY=`TZ=bb24 date +%Y%m%d`

YESTERDAYS_AUDIT_FILE=”audit_$YESTERDAY”

#Login to file server to put the latest audit file there

ftp <IP> << cmd

bin

lcd /usr/sap/SID/DVEBMGS<SN>/log

cd /SID

put  $YESTERDAYS_AUDIT_FILE

bye                         

3)Crontab entry to run this script daily:

crontab -e

#Sending Daily Audit Logs to XXXXX Server

0 7 * * * /tmp/FtpDailyAudit.sh 1>/dev/null 2>/dev/null              

Assigned tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.