473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

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
Jul 20 '05 #1
5 8580
Narine (na***************@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, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2


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!
Jul 20 '05 #3
Narine Kostandyan (na***************@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, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #4
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
<na***************@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!


Jul 20 '05 #5
kgard
1
I'm having the same problem. I have a C# console app that returns a 0 for success and a 1 for failure. Even though it returns a 1 and displays the error in the output, it still displays NULL in the return code output. How can I get the return value generated from the C# executable to be assigned to this return value in SQL. Also, even upon failure, the job will still display that it was executed successfully. Please help.

thanks.
Jun 30 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ryan | last post by:
I have a table in my database on SQL Server which holds a file name that refers to a file that is stored on the server. I would like to create a trigger to delete this file from the server if the...
1
by: Dan Bart | last post by:
I need to execute xp_cmdshell in a trigger and pass a command line parameter to the .exe program i.e. I have a .exe program c:\program files\savedata.exe In the trigger I have a parameter @Id...
4
by: Joel Thornton | last post by:
Whenever something is inserted to a given table, I want to run some shell commands using xp_cmdshell. Would it be a bad idea to put this xp_cmdshell in the INSERT trigger of this table? I...
4
by: Narine | last post by:
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...
10
by: Alex | last post by:
Hi, How would I go about writing the results of an SQL query to a text file? I cannot find any info in the Online help files. For example, I would like the results of: SELECT * FROM...
2
by: cpeters5 | last post by:
Deaa group, I am using SQLServer 2000 in an XP Sp2. I would like to do the following: I have a program running on a database server that generates some data which are loaded to the database....
3
by: phantom | last post by:
Greetings, I have a sp that dumps text into a textfile but I am having trouble creating the textfile. EXEC master.dbo.xp_cmdShell '\\servername\d$\The File\sub\filename.dat' The directory...
0
by: mcolson | last post by:
I am trying to execute a batch file using xp_cmdshell: EXEC xp_cmdshell 'c:\testing\runbattest.bat' When I do this, I get an output that says "Access is denied." Here are the contents of my...
7
by: FutureShock | last post by:
I have been using SQL Server 2005 for a total of 2 days and am trying to transfer table data from one server to another. For whatever reason the original operator only gave us the DB in a BAK...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.