all groups > sql server (alternate) > april 2004 >
You're in the

sql server (alternate)

group:

Output to the log file with XP_CMDSHELL


Output to the log file with XP_CMDSHELL narine.kostandyan NO[at]SPAM prurealty.com
4/28/2004 12:38:33 PM
sql server (alternate):
Hi Folks,

I am using an xp_cmdshell sp to start a C# app. This app downloads
data files and imports them into DB. It has a logging functionality
built-in and when executed from the command line or WE, it records
it's progress into a log TXT file. But when executed via xp_cmdshell,
it doesn't write into its log file.

Is it possible to enable it to write into a log file with xp_cmdshell?
Should I be using a different extended sp to accomplish that?

Any help will be greatly appreciated.

Thank you,
Re: Output to the log file with XP_CMDSHELL Erland Sommarskog
4/28/2004 10:08:46 PM
Narine (narine.kostandyan@prurealty.com) writes:
[quoted text, click to view]

Maybe you are looking for the log file in the wrong place? How does the
C# app determine where to write? The current directory when you run
xp_cmdshell is SYSTEM32 on the server machine.

Apart from the logging, does the app do its job?


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
Re: Output to the log file with XP_CMDSHELL Narine Kostandyan
4/28/2004 11:56:53 PM


Thank you for replying, Erland.
C# app works fine, we've had it running as a scheduled task for a while.
The problem is after this app runs successsfully we need to execute a
DTS package. Until now it's been running as two independent processes.
DTS is scheduled to run a little after the app. I wanted to create a
stored procedure that will execute an app and on success execute DTS
package.
This will not only ensure that DTS will run on success but also will
require only one job scheduled.
However, we do need to look at the C# app logs to understand errors
better.
Another alternative would be to write a VB script that will execute the
app then use dtsrun utility to execute the package.


*** Sent via Developersdex http://www.developersdex.com ***
Re: Output to the log file with XP_CMDSHELL Ellen K.
4/29/2004 9:23:11 PM
An executable can be a job step. The only trick is that you have to
make it finish with a return value that Agent can understand as
success or failure.

On 28 Apr 2004 23:56:53 GMT, Narine Kostandyan
[quoted text, click to view]
Re: Output to the log file with XP_CMDSHELL Erland Sommarskog
4/29/2004 9:28:05 PM
Narine Kostandyan (narine.kostandyan@prurealty.com) writes:
[quoted text, click to view]

OK, if the C# app runs well, I would assume that is also writing its
logs properly. I mean, if that particular part would fail, the application
would fail too, wouldn't it?

In case it doesn't, write some error-checking where you open the log file,
and print an error message to standard output - this would become a result
set from xp_cmdshell.


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
AddThis Social Bookmark Button