Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 running batch file

Author  Topic 

mikejohnson
Posting Yak Master

153 Posts

Posted - 2004-12-16 : 15:34:28
i have the following code:

declare @command varchar(200)
set @command = 'call d:\inetpub\achfiles\avantis\achreturn.bat'
exec master..xp_cmdshell @command

if i run the command from a dos prompt on the server it works fine. if i run it from QA it just sits there until i cancel it and time it out. i have a similar batch file that i call just like this one that works just fine from QA and the dos prompt.....

mikejohnson
Posting Yak Master

153 Posts

Posted - 2004-12-16 : 15:35:18
after i cancel it and it shows the timeout, i get this message:

ODBC: Msg 0, Level 16, State 1
Communication link failure

Connection Broken
Go to Top of Page

mprolli
Starting Member

24 Posts

Posted - 2004-12-16 : 16:03:14
What the batch file do?

Let us rise up and be thankful, for if we didn't learn a lot today, at least we learned a little, and if we didn't learn a little, at least we didn't get sick, and if we got sick, at least we didn't die; so, let us all be thankful.
--Buddha
Go to Top of Page

mikejohnson
Posting Yak Master

153 Posts

Posted - 2004-12-16 : 16:28:57
well, the first batch file that works using both qa and dos uploads a file to a secure https site. the second one that only works in dos and not qa downloads files from the site. again, it works fine if i actually run the same code in dos, just not when i run it from qa................
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-12-16 : 16:33:36
I'd suggest putting the DOS code into a job rather than calling it from xp_cmdshell. That at least will prevent it from hanging your SQL session. You can start the job using the sp_start_job procedure. Once the job starts it will run on its own. You can mix and match DOS and T-SQL steps in the job and control the workflow too.
Go to Top of Page

mikejohnson
Posting Yak Master

153 Posts

Posted - 2004-12-16 : 17:46:36
do i just choose operating system command (cmdexec) and then type my dos commands?
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-12-16 : 17:49:46
Exactly. I've not tested if it can do more than one DOS command per step, but if it can't then you just use multiple steps.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-12-16 : 17:58:32
To test this, log into the database server using the account that is used for the MSSQLSERVER service. Then run the batch file from a cmd window. What happens there?

This simulates what happens from a job or from xp_cmdshell since both use the MSSQLSERVER service account. If yours is set to Local System Account, then that could be the problem.

Tara
Go to Top of Page

mikejohnson
Posting Yak Master

153 Posts

Posted - 2004-12-16 : 18:16:24
still works in a command window but not in the job. doesn't error out or time out in the job though. doesn't make sense. other batch files works perfectly using job or sp but this one doesn't
Go to Top of Page

mikejohnson
Posting Yak Master

153 Posts

Posted - 2004-12-17 : 10:27:54
can you think of anything else?
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-12-17 : 11:34:25
It would help if you show us what's in the batch file...



Brett

8-)
Go to Top of Page
   

- Advertisement -