Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to execute a Unix shell script from Windows

I've got an AIX script I would like to run from a .NET application. I'm not opposed to kicking off a Windows batch file if that gives me better options.

Most of what I've seen on Google relates to using a tool such as rsh or Plink, or using ssh or telnet. I don't have access to rsh or Plink (although I do have PuTTY and could probably get Plink). I can ssh to the AIX box but telnet is disabled.

I'll need a way of passing the user's credentials.

Can anyone recommend the best way to call a Unix script from a Windows application?

like image 440
John M Gant Avatar asked Apr 21 '09 14:04

John M Gant


1 Answers

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.

like image 119
Tanktalus Avatar answered Nov 15 '22 06:11

Tanktalus