?
Solved

SQL xp_cmdshell errors. MSSQL, Programming, ImageMagick

Posted on 2011-09-12
8
Medium Priority
?
449 Views
Last Modified: 2012-05-12
Hello experts,

I’m experiencing some trouble with xp_cmdshell in SQL.  It appears that, though I can easily call ImageMagick through the command prompt, but SQL won’t allow me to run the commands through xp_cmdshell.  

I can currently run other batch scripts, programs, and basic move and copy commands with xp_cmdshell, but not the following script:

EXEC master.dbo.xp_cmdshell 'convert "C:\TESTS\20_pg_tiff_bia.TIF" "C:\TESTS\20_pg_tiff_bia_%d.TIF"'
Errors:  Invalid Parameter - "C:\TESTS\20_pg_tiff_bia_%d.TIF"
NULL

Simplifying the expression still causes errors:
EXEC master.dbo.xp_cmdshell 'convert "C:\TESTS\20_pg_tiff_bia.TIF" "C:\TESTS\20_pg_tiff_bia2.TIF"'
Errors:  Invalid Parameter - "C:\TESTS\20_pg_tiff_bia2.TIF"
NULL

Both of these calls without issues when invoked through cmd:
convert "C:\TESTS\20_pg_tiff_bia.TIF" "C:\TESTS\20_pg_tiff_bia_%d.TIF"
convert "C:\TESTS\20_pg_tiff_bia.TIF" "C:\TESTS\20_pg_tiff_bia2.TIF"

Any ideas?
0
Comment
Question by:robthomas09
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 22

Expert Comment

by:pivar
ID: 36526065
Hi,

Can you try to use the path to convert exe?

EXEC master.dbo.xp_cmdshell 'C:\[path to ImageMagick convert binary]\convert "C:\TESTS\20_pg_tiff_bia.TIF" "C:\TESTS\20_pg_tiff_bia2.TIF"'

It might be that you have another convert on your path.

/peter
0
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 36539134
If that doesn't work try it like this...

declare @shellcmd varchar(500)

set @shellcmd = 'C:\[path to ImageMagick convert binary]\convert "C:\TESTS\20_pg_tiff_bia.TIF" "C:\TESTS\20_pg_tiff_bia2.TIF"'

exec master.dbo.xp_cmdshell @shellcmd
0
 

Author Comment

by:robthomas09
ID: 36568060
No dice on either of those.  Could the VBS be stalling out, or something?
0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 36568214
What vbs??  I thought you were running a program called "convert.exe"
..no?

Did you get the same error this time, or a different error?



0
 
LVL 25

Expert Comment

by:Ron Malmstead
ID: 36568223
--Please try this...
--And make sure the files exist first.

declare @shellcmd varchar(500)

set @shellcmd = 'convert C:\TESTS\20_pg_tiff_bia.TIF C:\TESTS\20_pg_tiff_bia2.TIF'

exec master.dbo.xp_cmdshell @shellcmd
0
 

Author Comment

by:robthomas09
ID: 36568623
I'm sorry -- VBS was a workaround I tried, referring to another post: http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SQL_Server_2008/Q_27317780.html 

Assigning the shell cmd into a variable doesn't working, either, xuserx2000.  Still the exact same parameter error.
0
 
LVL 25

Accepted Solution

by:
Ron Malmstead earned 2000 total points
ID: 36568739
"Invalid Parameter - C:\TESTS\20_pg_tiff_bia2.TIF"

That is an error coming from the "Convert" application.
The shellcmd is working as it is expected to and returning the output from the "convert" app.

Convert is an application built into windows to convert an HD to filesystem.. NTFS or FAT32.

Please supply the full path to imagemagick/convert application, I believe windows is getting confused and running the filesystem convert program.
0
 

Author Closing Comment

by:robthomas09
ID: 36569110
Thank you!
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

741 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question