0

I have been trying to call a GraphicsMagick command through the T-SQL xp_cmdshell procedure, but I am getting errors with the same.

The command I am trying to call is as below : gm convert "\dklyefxdb1\X\Backup\apple_raw.jpg" -scale 200x250 "\dklyefxdb1\X\Backup\apple_raw_resize.jpg"

The SQL code which I am executing is as follows :

Exec sp_configure 'xp_cmdshell', 1
Reconfigure
GO

exec xp_cmdshell 'gm convert "\\dklyefxdb1\X\Backup\apple_raw.jpg" -scale 200x250 "\\dklyefxdb1\X\Backup\apple_raw_resize.jpg"'
GO

I am getting the following error after executing this code:

'gm' is not recognized as an internal or external command, operable program or batch file.

Please note that GraphicsMagick is installed on the Server where SQL Server sits.

Other point to note here is that if I run the same command through cmd on the server, it runs successfully.

Any help would be appreciated.

1 Answers1

0

Add full path to gm:

exec xp_cmdshell 'C:\..\gm convert "\\dklyefxdb1\X\Backup\apple_raw.jpg" -scale 200x250 "\\dklyefxdb1\X\Backup\apple_raw_resize.jpg"'

or SET PATH environment variable

Lukasz Szozda
  • 162,964
  • 23
  • 234
  • 275