1827470 Members
2587 Online
109965 Solutions
New Discussion

cron jobs

 
khilari
Regular Advisor

cron jobs

Hi people, well i have to send a cron job to another system. Like there is a file which needs to be transferred to another system every morning.
What i want is a simple script which would transfer the file and over write the existing one in that particular folder. Now, should i put an ftp clause to do it.

Suggestions please??

Thanks
6 REPLIES 6
spex
Honored Contributor

Re: cron jobs

Hi khilari,

#!/usr/bin/sh

#Set vars in the following block
host=foo
username=user2
password=hello
dir_src=/home/user1
dir_dest=/
filename=myfile.text

ftp -n << _EOF_
open ${host}
user ${username} ${password}
put ${dir_src}/${filename} ${dir_dest}
bye
_EOF_

Remember that ${dir_dest} is based on the directory structure displayed by FTP.

PCS
James R. Ferguson
Acclaimed Contributor

Re: cron jobs

Hi Khilari:

The simplest approach might be to 'rcp' the file that you want copied:

# rcp -p /var/tmp/myfile otherhost:/var/tmp/myfile

You will need to establish a 'hosts.equiv' or '.rhosts' file on both servers. See the manpages for 'hosts-equiv(4)' for more information on this.

Setup an appropriate crontask and you should be done.

Regards!

...JRF...
khilari
Regular Advisor

Re: cron jobs

well i have to transfer from an hp unix box to a windows machine............
A. Clay Stephenson
Acclaimed Contributor

Re: cron jobs

In that case an option would be to use CIFS 9000 (Samba) to either mount the UNIX directory on the Windows box or vice-versa. You can also use FTP but there must be an FTP service running on the Windows server is you want to initiate the transfer from the UNIX side.
If it ain't broke, I can fix that.
spex
Honored Contributor

Re: cron jobs

khilari,

You have many options for how to transfer the file. A couple more to consider:

email as an attachment
======================
( echo "You will find myfile.gz attached."
uuencode myfile.gz myfile.gz ) | mailx -m -s "[$(date +%m\/%d\/%y)] myfile.gz" my@email.addr

scp from the Windows box
(if you have sshd running under HP-UX)
===========================================
1. Generate a public/private key pair.
2. scp user2@hpux01:~/myfile.gz .

PCS
Bill Hassell
Honored Contributor

Re: cron jobs

Note that most Windows boxes cannot answer an incoming ftp request be default. You need to enable the ftp server feature (assuming it even exists on your versin of Windows). If the boxes are both internal, then ftp is the best choice. If the boxes are remote, then ftp is a very poor choice as it does not encrypt the data so snoopers can see the data.

Secure Shell (SSH or sftp and scp) do not exist in Windows so you'll have to add an SSH package to enable encrypted data transfers.


Bill Hassell, sysadmin