0

I am trying to execute a perl script from xp_cmdshell.

The output of the perl script is a csv file, but when I run

EXEC master..xp_cmdshell N'perl G:\script\perl.pl';

I can't find the csv file created, though the xp_cmdshell command seems to run fine, the output is the name of file that has to be created.

I am using xp_cmdshell to create a job step to execute the perl script.

Any help would be appreciated.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Giovanni De Ciantis
  • 357
  • 1
  • 2
  • 11

1 Answers1

1

Since you're running this via a SQL Agent job, it'll be much safer to disable the use of xp_cmdshell via sp_configure (ref1 | ref2) and use a CmdExec job step instead.

When configuring the job step, be sure to go to the advanced page and enable job step logging to a table.

Verbose Logging

This will allow you to better troubleshoot the issues you're having with the perl job in general, as the issue could be related to something entirely outside the context of the database engine.

John Eisbrener
  • 642
  • 8
  • 17
  • tnx for the reply , but I can't figure out where the file has been saved. `Job 'test' : Step 1, 'esecuzione' : Began Executing 2016-05-03 15:59:41 output 03_05_2016_155942_output.csv (null) (2 rows(s) affected)` – Giovanni De Ciantis May 03 '16 at 14:15
  • What does the job output show? Go back into the job, edit the step, go to the advanced page and then click the "View" button. This should show the step output. If it's not shown there, you likely need to edit your perl script in case it's creating the output at a static path. – John Eisbrener May 03 '16 at 14:37
  • The job output shows what I wrote in the previous comment. By the way I solved, as you suggested, adding to perl script a static path. Many tnx @john – Giovanni De Ciantis May 03 '16 at 15:24