- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- to automate the sftp or ftp or scp download files ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 08:01 PM
тАО04-06-2009 08:01 PM
to automate the sftp or ftp or scp download files from unix to windows
would like to seek your advice. we would like to automate the downloading files from unix to windows in cron on weekly basis. i have the following doubts, would really appreciate your advice.
1. can sftp from unix to windows?
2. i want to remove the the files upon the ftp successfuly login. can we just compare the destination and source after we completed the the downloading, and if it is the same file name or count, do remove the file from source?
3. how to output this download log to textfile.
herewith is my simple script and entry in cron tab for your comments and advice.
# more autoftp.txt
!/usr/bin/ksh
ftp -v -i -d -n 120.1.1.90
user apple apple1
cd /tmp/nmon
lcd C:/Temp/perf
mput *.nmon
bye
# crotab -l
30 22 * * 5 /appl/scripts/rcp/auto_rcpfile 1>/dev/null 2>/dev/null
hope to hear from you. promise of good points.Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-06-2009 08:34 PM
тАО04-06-2009 08:34 PM
Re: to automate the sftp or ftp or scp download files from unix to windows
Perhaps, if your Windows system runs an SFTP
server. Have you tried SFTP to your Windows
system? SCP? (SSH?)
> ftp -v -i -d -n 120.1.1.90
Have you tried FTP to your Windows system?
2. [...] can we just compare [...]
Compare how?
> [...] same file name or count [...]
Is that what's important to you, or do the
actual data matter?
> 3. how to output this download log to
> textfile.
"> textfile"? Something other than
"1>/dev/null 2>/dev/null" might save more.
> herewith is my simple script [...]
Have you tried it?
> user apple apple1
I see that security is not important.
> cd /tmp/nmon
> lcd C:/Temp/perf
Which system is the Windows system?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2009 12:05 AM
тАО04-07-2009 12:05 AM
Re: to automate the sftp or ftp or scp download files from unix to windows
this is what i would do, i would install cygwin on windows and use scp instead of sftp.
you need to add the neccessary modules like SSH while installing cygwin , so that you can place the scp script on windows and it can pull the logfiles from the server.
please let me know if you need more help.
http://www.cygwin.com/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2009 01:28 AM
тАО04-07-2009 01:28 AM
Re: to automate the sftp or ftp or scp download files from unix to windows
First decide which mode(ftp or sftp) you are going to use for file transfer. If you are going to use ftp steps are very simple.
If it is ftp these are the steps you need to follow.
We can setup a cron job on unix server to copy the files. Instead of removing the source file after copying, it is better to backup those files and compress it for future. Later on you can remove the backup compress files.
Assuming you have account called apple with password apple123 on windows server. Windows server ip is 10.15.20.100
on unix server edit the $HOME/.netrc file and put the below entry. This is to login ftp without password..
#vi $HOME/.netrc
machine 10.15.20.100 login apple passwd apple123
Create a script to automate the job
#vi /tmp/nmon/ftpjob
export LOG=/tmp/nmon/log
export ARCH=/tmp/nmon/archive/
export FIL="*.nmon"
echo " " >> ${LOG}
#------------------------------------------------------
# Check for file to transfer to windows
#------------------------------------------------------
cd /tmp/nmon
files=`ls |grep ${FIL} |wc -l`
if [ $files -gt 0 ]
then
echo "File: `ls|grep ${FIL}`" >> ${LOG}
ftp 10.15.20.100 << EOF
bin
mput ${FIL}*
bye
EOF
mv ${FIL}* ${ARCH}
else
echo "No file to windows" >> ${LOG}
exit 1
fi
exit
Put this job in cron like below..
30 22 * * 5 /tmp/nmon/ftpjob >> /tmp/nmon/ftpjob.log 2>&1
Ganesh.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-07-2009 03:15 AM
тАО04-07-2009 03:15 AM
Re: to automate the sftp or ftp or scp download files from unix to windows
If you decided to use sftp things are little different. First you need to configure password less login for the account which is going to run the script between the unix server and windows server. Script should be like this...
#-------------------------------------------------------
# Put files to Windows using sftp
#-------------------------------------------------------
LOG=/tmp/nmon/log
TODAY=`date +'%d%b%y'`
#-------------------------------------------------------
# Any files received for transfer?
#-------------------------------------------------------
fn=`ls /tmp/nmon`
if [ ${fn:-NO} = "NO" ];
then
echo "No file" >> $LOG
exit
else
echo "Files to send: $fn" >> $LOG
#-------------------------------------------------------
# Connect to windows server and put the files
#-------------------------------------------------------
sftp username@10.15.20.100 <<**
lcd /tmp/nmon
mput *.nmon
**
#-------------------------------------------------------
# Cleanup
#-------------------------------------------------------
cd
mv /tmp/nmon/$fn /tmp/nmon/archive/$fn.$TODAY
compress /tmp/nmon/$fn.$TODAY
rm /tmp/nmon/*.nmon
fi
put this script on crontab. Script will work only if password less login is configured between unix and windows server.
Ganesh.