How to execute a Unix shell script from Windows How to execute a Unix shell script from Windows unix unix

How to execute a Unix shell script from Windows


Install cygwin. Include the ssh function. Set up your ssh keys - private key on windows, public key on the AIX box. Then you can run "ssh user@aixbox script-on-aix-box.sh".

Best to have the script on AIX, though you can use scp to copy the file to AIX first. Passing a long command line through ssh is error prone - not due to it being ssh, but because getting escapes properly set up to pass from .NET through ssh to ksh or whatever is running on AIX is just painful. Best to keep things as simple as possible, preferably just a single command which can then be a script that does multiple things.

To answer your comments, which would take too long for another comment:

(1) Why is it better to use cygwin's ssh utility instead of the Windows ssh utility?

a) I know it better, so I wouldn't know to suggest any windows ssh utility (I didn't even know Windows came with an ssh utility), and b) cygwin's ssh utility stands a better chance of being standard ssh with all the familiarity us unix freaks love. :-)

(2) What are the keys for? Does that allow cross-platform authentication, or is it just a way of asymmetrically encrypting the password?

The keys allow passwordless access. If you set up your private key as passwordless (not usually recommended, but if you can keep your machine secure, it works well for automated tools), your tool will be able to just ssh over with no password prompts - this makes things much easier.


ssh eximadmin@172.16.12.10 "cat somefile.log"

(where cat somefile.log is replaced with the command that you want to run)

I think the easiest way to do it would be to call your ssh program (whether that be ssh, plink, or something else) from a batch file that is called from your .net app.


I second the cygwin suggestion, but one other option that you have is Microsoft's Services for UNIX.