Operating System - HP-UX
1825941 Members
2519 Online
109689 Solutions
New Discussion

Re: need script to FTP file from UNIX to NT

 
SOLVED
Go to solution
Donna Yedziniak_1
Occasional Contributor

need script to FTP file from UNIX to NT

I have a HP 9000 N series server and need a script that will check for the existence of a file on that server and then will FTP that file and one other to a NT server on the same network. Once the tranfer is complete, it will then delete those two files. This script will be a nightly process setup in cron to check for this first file and then run.

Any help to get me started would be greatly appreciated.

Thanks,
Donna Yedziniak
6 REPLIES 6
harry d brown jr
Honored Contributor

Re: need script to FTP file from UNIX to NT

TO get started, do you have an FTP agent on your NT? If not, you will need one, because NT does not allow ftp by default.

live free or die
harry
Live Free or Die
Christopher Caldwell
Honored Contributor

Re: need script to FTP file from UNIX to NT

Check for the existence of a file, then
if [ -f name_of_file ]
{more stuff goes here}

ftp -n -v >> ftpLOG' 2>> 'ftpLOG' <<-EOF
open address.of.your.host
lcd $directory_where_the_file_is
user username password
binary
put $ftp_file_name
quit
EOF
Dave La Mar
Honored Contributor
Solution

Re: need script to FTP file from UNIX to NT

Attached is a down and dirty of what you wish to accomplish.
Good Luck.
dl
"I'm not dumb. I just have a command of thoroughly useless information."
Dave La Mar
Honored Contributor

Re: need script to FTP file from UNIX to NT

Sorry, I forgot this one to schedule in cron which calls the other two based on return codes.
dl


Script to schedule in cron which will call Script I followed
by Script II

#! /bin/ksh
############################################################################
# Get the date/time for input on email if necessary. #
# If the file exists send it by calling your ftp script. #
# Else mail the date and time of failure to someone who cares. #
############################################################################
date > date_file
if [ -f /path/your_file_name ]
then
/usr/local/bin/ftp_myfile
else
mailx -s "File did not exist" dlamar@gottschalks.com < /path_name/date_file
fi
"I'm not dumb. I just have a command of thoroughly useless information."
Dave La Mar
Honored Contributor

Re: need script to FTP file from UNIX to NT

Sorry, I forgot this one to schedule in cron which calls the other two based on return codes.
dl


Script to schedule in cron which will call Script I followed
by Script II

#! /bin/ksh
############################################################################
# Get the date/time for input on email if necessary. #
# If the file exists send it by calling your ftp script. #
# Else mail the date and time of failure to someone who cares. #
############################################################################
date > date_file
if [ -f /path/your_file_name ]
then
/usr/local/bin/ftp_myfile
else
mailx -s "File did not exist" dlamar@gottschalks.com < /path_name/date_file
fi
"I'm not dumb. I just have a command of thoroughly useless information."
Donna Yedziniak_1
Occasional Contributor

Re: need script to FTP file from UNIX to NT

This is great guys!

I'll give it a try.

Thanks,
Donna