Unix Technical Forum

Output to the log file with XP_CMDSHELL

This is a discussion on Output to the log file with XP_CMDSHELL within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi Folks, I am using an xp_cmdshell sp to start a C# app. This app downloads data files and ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 02:39 AM
Narine
 
Posts: n/a
Default Output to the log file with XP_CMDSHELL

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,
Narine
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 02:39 AM
Erland Sommarskog
 
Posts: n/a
Default Re: Output to the log file with XP_CMDSHELL

Narine (narine.kostandyan@prurealty.com) writes:
> 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?


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
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-29-2008, 02:39 AM
Narine Kostandyan
 
Posts: n/a
Default Re: Output to the log file with XP_CMDSHELL



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 ***
Don't just participate in USENET...get rewarded for it!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-29-2008, 02:39 AM
Erland Sommarskog
 
Posts: n/a
Default Re: Output to the log file with XP_CMDSHELL

Narine Kostandyan (narine.kostandyan@prurealty.com) writes:
> 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.


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
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-29-2008, 02:40 AM
Ellen K.
 
Posts: n/a
Default Re: Output to the log file with XP_CMDSHELL

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
<narine.kostandyan@prurealty.com> wrote:

>
>
>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 ***
>Don't just participate in USENET...get rewarded for it!


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:55 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com