1

I have housekeeping script which is running on Redhat operating system.

I have a requirement where i want to run the same script in the Windows environment.

So i have 3 options

  1. Write a new script for windows
  2. Convert Linux script in to windows script using some tool.
  3. Use Cygwin and run the script without making any change to the linux script.

So i want to know what would be the best option to select.

Thanks in advance for any help

Attila
  • 28,265
  • 3
  • 46
  • 55
KItis
  • 5,476
  • 19
  • 64
  • 112
  • 1
    it depends on what the script does... windows batch are not powerfull as shell-script. of course you can use javascript or powershell if you have knowledge of them. – BigMike May 14 '12 at 10:27
  • using java-script or power shell meanings going for option 1 right? – KItis May 14 '12 at 10:35
  • exactly, but using the right tools for the right task can help. Take a look at robocopy, is easy to use it in simple .cmd / .bat and may just solve your whole problem with just a oneline. – BigMike May 14 '12 at 10:36
  • It's impossible to say what the correct approach is without some details about the script, preferably seeing it in its entirety. What commands do you rely on? Of those, which are standard tools and which are RH-specific? Do you touch any files and how do you reference the file paths? All of these questions would need to be answered. – sorpigal May 14 '12 at 11:03

5 Answers5

7

It depends on how complex the scripts are, whether you want to make changes to them and what utilities the existing ones use.

If the scripts are very complex, you will be better off keeping the original and use Cygwin.

If you want to maintain the scripts and port changes back and forth, you will want to use the original (and use Cygwin)

If the script uses some Unix utilities that have not been ported to Cygwin, you either need to do the porting yourself (to be able to keep the original scripts) or convert the scripts to use Windows equivalent (or similar) programs

So I'd recommend you using Cygwin in most cases, unless the scripts are very easy to translate to Windows batch format

Attila
  • 28,265
  • 3
  • 46
  • 55
1

You can try colinux

http://www.colinux.org/

Cooperative Linux is the first working free and open source method for optimally running Linux on Microsoft Windows natively. More generally, Cooperative Linux (short-named coLinux) is a port of the Linux kernel that allows it to run cooperatively alongside another operating system on a single machine.

Andreas Wong
  • 59,630
  • 19
  • 106
  • 123
1

I would recommend option 3 and it is the only way to run the same script (assuming script = bash script) under windows.

c2h2
  • 11,911
  • 13
  • 48
  • 60
  • when i select that option, i need to run the script as a cronjob, so how do i do that with cygwin. do you have answer to that. cronjob is not available in cygwin – KItis May 14 '12 at 10:28
  • You can: http://stackoverflow.com/questions/707184/how-do-you-run-a-crontab-in-cygwin-on-windows – c2h2 May 14 '12 at 10:30
1

4: Install a port of BASH for windows, e.g. win-bash
5: Use SUA/SFU, see this link

Jay M
  • 3,736
  • 1
  • 24
  • 33
1

As stated in comment, I'd like to see or know what the script does. Under windows there are a couple of options for scripting now. (Powershell, vbscript, javascript, plain old batch files), but really it depends on what the original script does.

IMHO is just plain overkill installing the whole cygwin or a bash porting just for moving files or performing other trivial tasks.

BigMike
  • 6,683
  • 1
  • 23
  • 24
  • original script is a housekeeping script for deleting old log files and archiving log files which are older than given time period – KItis May 14 '12 at 10:30
  • the answer to your needs can be robocopy (a good utility that manages file copies). – BigMike May 14 '12 at 10:32