Monday, March 12, 2012

Run java script applet from stored procedure?

Here's a good newbie question. Can I run a command-line applet from a stored procedure?

I'm running a java script applet to convert .tif files to .pdf files and have a handy applet for such. The .tif files get dumped by a fax server into a particular directory. After conversion I need to move the new .pdf files to a different directory. For me this is a VB Script project for a DTS package that gets scheduled to run every x minutes.

Is there a better way to do this from a sp? I keep hearing that you can do anything in a sp that you can do in a DTS package.

Thanks for the help!try using the system stored proc "xp_cmdshell," it takes the command as input and can return the results as well.

Not sure what you are trying to do, but this may work!|||xp_cmdshell looks like it is just the ticket, however it isn't working for me--yet.

Here's what I wrote (OK, I copied it from the Help files):

========================================

CREATE PROCEDURE sp_FileConverter AS

declare @.result int

exec @.result = xp_cmdshell '%WINDIR%\SYSTEM32\cscript.exe C:\Program Files\Aquaforest\TIFF Junction\wsh\tiff2pdf.js C:\Access_Test\Fax'

IF (@.result = 0)
PRINT 'Success'
ELSE
PRINT 'Failure'
GO

==========================================

When I try to run it I get "Could not find stored procedure 'xp_cmdshell'." Most annoying!

What can I do to help SQL Server find it's own system sp?

Thanks!|||try "master..xp_cmdshell"|||Whohooo! That did it. At least SQL Server is happy with this now.

Now, on to figuring out why my applet has stopped running! It's always something...

Thanks for your help!

No comments:

Post a Comment