110 pts.
 Shell script within Stored Procedure
How do I execute a UNIX shell (.sh) script from within an MS SQL Stored Procedure?

Software/Hardware used:
ASKED: April 7, 2009  2:11 PM
UPDATED: April 20, 2009  11:07 PM

Answer Wiki:
Last Wiki Answer Submitted:  Be the first to answer this question.
All Answer Wiki Contributors:  Be the first to answer this question.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

What version of Unix/Linux are you using or is it on a windows machine?

 27,325 pts.

 

As SQL Server only runs on Windows, are you trying to run a Unix script on Windows, or do you need to log into a Unix server then run the Unix script?

 64,550 pts.

 

The stored procedure itself will run on a Windows 2003 Server (SQL 2005).
The script should connect to a Solaris 10 (UNIX) box to execute some commands.

 110 pts.

 

>
> The stored procedure itself will run on a Windows 2003 Server (SQL 2005).
> The script should connect to a Solaris 10 (UNIX) box to execute some commands.
>

So, then the easiest way will be to write and put shell script on the UNIX box, then the stored procedure should just call rsh/ssh client and execute the script.

Sure, you should (1) install some windows port of rsh/ssh on win2003 system, and (2) make arrangements for the non-interactive login (e.g., non-password protected ssh private key on win2003 system, or some rhosts assignments on the solaris system – of course, the environment should be secure enough). My advice would be to go with ssh – not because of encryption and security, unattended login should create security hole anyway, but because of ease of setup: rsh is a protocol quite tricky for firewalls.

BR and good luck,

Petko

 3,120 pts.