Creating a ksh script to copy a folder

Hi Folks,

I need help in creating a ksh script to copy a folder from one server to multiple other servers using ssh and sftp.

The thing is the folder name changes daily. So is there a way we could specify the folder name during the execution of script.?

I would appreciate a quicker help. Its sort of emergency!!

Thanks,
Lena

What operating system are you using?

What version of the Korn shell are you using?

Exactly what command would you use to copy the source directory to one of the target servers?

Is the list of servers to which you want to copy files fixed? If so, where is the list? If not, how do you expect your script to know which servers are to be used?

What folder is to be copied? Is it a constant, or does it change every day?

Does your script need to ask the name of the target directory? Or, will you give your script the name of the target directory as a command line operand? Or, is the target directory name derivable from the current day's date?

Is the target directory the same path on each target server? Or, does each target server have a different target directory?

What have you tried to make this work on your own?

Hi Don,

First of all thank you so much for you response.

Please find my answers inline

What operating system are you using?
[L]: unix

What version of the Korn shell are you using?
[L]: no idea

Exactly what command would you use to copy the source directory to one of the target servers?
[L]: Am thinkning of using scp for secure copying.

Is the list of servers to which you want to copy files fixed? If so, where is the list? If not, how do you expect your script to know which servers are to be used?
[L]: yes, the lists are fixed and i would save it as a conf file(EX. servername.conf), so that the target directory/path would be retrieved from the conf file.

What folder is to be copied? Is it a constant, or does it change every day?
[L]: It changes daily or as required.

Does your script need to ask the name of the target directory? Or, will you give your script the name of the target directory as a command line operand? Or, is the target directory name derivable from the current day's date?
[L]: target directory/path should be retrieved from the conf file.

Is the target directory the same path on each target server? Or, does each target server have a different target directory?
[L]: same path on all server

What have you tried to make this work on your own?
[L]: I am actually new to scripting. I use to copy the files with the help of winscp. Thought of automating the process to reduce time and scripting is the way i came up with.

A little help on how to make this owrk would be helpful.

The easy way to write a script to do some is to figure out how to do it manually first and then build a script that incorporates that manual command (or set of commands) and puts it (or them) in a script with a little bit of boilerplate in a loop (since you want to repeat the process for a set of servers instead of just doing it for one server).

If you can't show us the exact command(s) you would type into ksh to copy files from your source folder to a destination folder on one of your target servers, and a sample of your configuration file format including at least the configuration details for the target server used in your example showing the commands you would use to manually copy files to that server, we can't help you automate your manual process.

Note that this is the UNIX and Linux Forums. My understanding is that winscp is intended for use on Windows systems; not UNIX and UNIX-like systems. When you need help with a script to run on Windows, you need to clearly state that up front. Are your destination servers also running Windows? (If not, what operating systems are they running.)

Note also that homework and coursework questions can only be posted in the Homework & Coursework forum under special homework rules. If this is a homework assignment, please review the guidelines for posting homework and repost in the proper forum.