Page 1 of 1

Transfer files to remote Linux system

Posted: 2021-Jul-25, 12:58 pm
by MigrationUser
18 Sep 2011 21:51
sarbjitsinghgill


Can some one suggest me a simplest way to transfer a text file from one linux to another.
This file will be transfered everyday at 12:10 am which will be analyzed by a tool at target system.

This has to be scripted .

Thanks in advance.

Sarbjit Singh Gill
IBM certified DBA, MQ Solution Developer

----------------------------

#2 02 Nov 2011 07:29
ramesh.subbu.2005


U can use ftp

script start :-
------------

Code: Select all

#!/bin/sh

if [ $# -lt 5 ] ; then
echo "Usage: EXENAME IP USER PASSWD REMOTEDIR REMOTEFILE"
exit 0;
fi

currentdate=`date +"%Y%m%d"`
yesterdaydate=`date +"%Y%m%d" --date="yesterday"`

echo $currentdate
echo $yesterdaydate

#HOST='192.168.1.63'
#USER='root'
#PASSWD='packet143.'
#FILE='file.txt'

HOST=$1
USER=$2
PASSWD=$3
DIR=$4
FILE=$5

ftp -in $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
cd $DIR
put $FILE
get $FILE
quit
END_SCRIPT

exit 0
------------
end of script


in this script u have to put in crontab

enter the linux terminal or console

Code: Select all

crontab -e

10 0 * * * script.sh
Ramesh Pasunoori

----------------------------

#3 02 Nov 2011 18:13
sarbjitsinghgill


Thanks again,
I had this going with scp, no problems.
scp is available on all , I doubt, here are many without FTP.

The script used for scp, thanks.

Sarbjit

Sarbjit Singh Gill
IBM certified DBA, MQ Solution Developer