1754315 Members
2731 Online
108813 Solutions
New Discussion юеВ

ftp in cron job

 
SOLVED
Go to solution
brian_31
Super Advisor

ftp in cron job

Need a cron job that automatically ftps certain kind of file with PGP encryption to a given ip. anyone know a way to accomplish this?

Thanks

brian
3 REPLIES 3
Steven Schweda
Honored Contributor

Re: ftp in cron job

Step 1. Figure out how to do the work.

Step 2. Write a shell script which does the
work.

Step 3. Tell "cron" to do the job
periodically, _if_ that's what you want done.


I'm sure that many people exist who could
solve this problem. Have you considered
hiring one of them?

Apparently you are not one of them, but if
you expect someone else to do the job for
you, whether paid or unpaid, you will almost
certainly need to define the problem better.
Interesting data would include what, exactly,
"automatically" means, what "certain kind of
file" means, which version of PGP is expected
to decrypt the stuff, whether a compatible
version of PGP is already available on your
system, and so on.

Even more interesting might be exactly what
the problem is which you are trying to solve.
There are may ways to arrange encrypted file
transfers beside using PGP encryption and
FTP.
Dave La Mar
Honored Contributor
Solution

Re: ftp in cron job

Brian -
Attached is a snippet from a working production script using ftp and pgp.
This is run from cron.
I'll assume you know the switches used in the pgp command.
Also note, that for the ftp, no user name or password are present since a .netrc file is used to store them.

Should you not know the use of .netrc just do a search for it on the forums, there is plenty of discussion.
Additionally, many ITRC users prefer using perl for the ftp due to it's built in error checking.

Best of luck on this.

Regards,

-dl
"I'm not dumb. I just have a command of thoroughly useless information."
Victor Fridyev
Honored Contributor

Re: ftp in cron job

Hi,

Create file .netrc in home directory of the user as follows

machine target_host
login USERNAME
password PASSWORD
macdef init
asci
cd incoming
lcd /tmp
put FILENAME
quit

As you see, you have to edit the file above according to your needs.


After that add the following string to the user's cron:

01 10 * * * ftp target_host

If you need to execute different actions on the same target_host, you will have to update (may be by an additional script) .netrc accordingly.

The only disadvantage of this is open user/password in text file.

HTH
Entities are not to be multiplied beyond necessity - RTFM