Schedule copy of files from UNIX

Hi, i am, to say the least, a UNIX novice.  I have access to Putty and WinSCP.  I would like to find a method to schedule and automate the copy of a set of files (everything with the current date) from a UNIX server to a windows directory.

can anyone point me in the right direction?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have 3 problems. Scheduling. Easy in both unix and windows. Second up is transfer, WinSCP was working, but you can also turn it around and install something on the Windows side. Third is probably the most tricky. That's the download logic.

You have to test a script either on the Unix side or Windows side. It doesn't really matter which side.
If it's the unix side, you have to make sure you can reach the windows directory. On the Windows side, either share a drive, or install Filezilla Server. Test script, after that, use a cronjob to schedule it.
If it's on the Windows side, test your winscp or ftp script, then schedule the job.

Probably having a script at the unix side is easier, as otherwise you have no way to select to correct files (current date), unless the file name has this info.

So, can you FTP to the Windows directory? That would make it a lot easier to follow up on this question.
greepAuthor Commented:
Hi, thanks for your reply, you will have to, please, forgive my extreme ignorance of UNIX commands!.
I can connect to the UNIX server using WINSCP, and manually drag/drop files to a mapped windows path.

But i am not clear how, in a script I reach the Windows side.

Could you perhaps give me an example script to copy files from a UNIX directory (with the current date) to a windows path?

then, if i create the script on the UNIX server, how do I execute it from Windows?
Again, 3 problems: Scheduling/Transport/Logic
You ask how to copy files from UNIX to windows. I'm missing the TRANSPORT part. How can the Unix machine reach the Windows PC? FTP ? SMB ?
Then you ask to execute a script on UNIX from the Windows PC, but I thought you wanted to schedule it (which has to be done on the Unix side of course). Executing a script in Unix has to be done from the shell, as in an SSH session in PuttY. The scheduling of the cronjob too.
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

It would probably be easiest to schedule the logic from the Linux side to pick out the dates.  Create a folder and put links to files that you like to copy from the linux side, then copy them from the windows side with winscp using schtasks or the GUI scheduler.

Create a folder to place the files that Winscp will copy from.
mkdir /path/to/link/folder

schedule a script to do the following;
find /path/to/folder -mtime 0 -exec ln -s {} /path/to/link/folder/ \;
The find command looks for files that have a mtime (modification time) of a 24 hour period, rounded up.  You can use other options for finer tuning, but this may be sufficient for your needs.

To see more details
man find

You may want to schedule another task to delete all the links before you schedule Winscp to run on Windows.
rm -r /path/to/link/folder/; mkdir /path/to/link/folder/
or if you don't have hidden dot files
rm -r /path/to/link/folder/*

or you could just place it ahead of the find command in the script.
you need to do 3 things:

1- have pscp (you can download to your windows):

2- have a unix username and password

3- schedule task to run on windows to run commands (could be a .bat file):

drivename: (e.g. c:)
cd \path]to\myfolder
c:\path\to\pscp.exe -l username -pw password hostname:/path/to/myfiles/*.*
greepAuthor Commented:
Thanks for your responses, I have found the solution.

A unix script  along these lines:

option batch abort
option confirm off
open sftp://userIid:password@unix.server
cd /server/directory
option transfer binary
get filename C:\destination\

saves as unixscript.txt

and executed from a batch file using the command line:

@echo off
C:\Progra~1\Winscp\ /console /script=C:\unixscript.txt

The batch file then added to the windows scheduler to fire at the desired time

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
A simple solution could have been provided by anyone. You seem to forget your original question was more intricate as indicated by "automate the copy of a set of files (everything with the current date)". Obviously, if you didn't mention that, a lot of people would have a script ready for you already. Your current script doesn't contain any of that logic.
greepAuthor Commented:
i managed to find the simpilest solution myself
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.