Sign in to follow this  
Followers 0
eidolon74

trying to run an osql statement

15 posts in this topic

Is it possible to run an osql statement in autoit? I have attached the lines I am currently working with. Any help would be appreciated.

RunWait(@COMSPEC & "osql.exe -U sa -P master -d $variable1 -Q ""select * from hl7patient" -o c:\hl7check.txt"")

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

you'd want to check out FAQ #7 for your quotes...

and I think that a /c would help this work.. all together:

RunWait(@COMSPEC & ' /c osql.exe -U sa -P master -d ' & $variable1 & ' -Q "select * from hl7patient" -o c:\hl7check.txt')

Something like that? dont' know osql, but hope that helps.

(edit, you snuck a variable in the middle there, fixed that.)

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Tried it..still get an error "unable to execute external program"..any other thoughts?

Share this post


Link to post
Share on other sites

You have to change osql.exe to the full path of osql.exe

Share this post


Link to post
Share on other sites

Ok...but what if the location of the file varies from system to system, yet the file will always be in the path. Is there anyway to get it to run without specifying the path?

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Can you try this....

(All in one line)

RunWait(@COMSPEC & ' /c ' & @ScriptDir & '\osql.exe -U sa -P master -d ' & $variable1 & ' -Q "select * from hl7patient" -o c:\hl7check.txt')
Edited by SlimShady

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Ok...but what if the location of the file varies from system to system, yet the file will always be in the path. Is there anyway to get it to run without specifying the path?

you can try using the start.exe . Edited by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

you could use regread to get the path to osql.exe, if it's in the registry... I don't have it installed... blah blah blah... shouldn't a command put through the run line work on something that's in the path? Have you tried with fixed quotes without the @comspec? this should be like running from the run line...

RunWait('osql.exe -U sa -P master -d ' & $variable1 & ' -Q "select * from hl7patient" -o c:\hl7check.txt')

or like jdeB said, try start:

RunWait('start osql.exe -U sa -P master -d ' & $variable1 & ' -Q "select * from hl7patient" -o c:\hl7check.txt')

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

2 things:I tried the script but i get the error "cannot open file"..secondly what is start.exe?

Again thanks for all of the help...anything else i can try?

Share this post


Link to post
Share on other sites

2 things:I tried the script but i get the error "cannot open file"..secondly what is start.exe?

Again thanks for all of the help...anything else i can try?

go to a command prompt and type start /? and you'll find a ton of info about start.

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

maybe if you copy the text of the error message (ctrl-c works on most autoit errors to get the text) and paste it here, that'd help?


"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Ok..thanks for the elaboration of start...but I tried it as suggested and still no dice. anything else?

Share this post


Link to post
Share on other sites

---------------------------

AutoIt Error

---------------------------

Line 50 (File "C:\Documents and Settings\keithdavenport\Desktop\hl7imp4.au3"):

RunWait('start osql.exe -U sa -P master -d ' & $variable1 & ' -Q "select * from hl7patient" -o c:\hl7check.txt') )

Error: Unable to execute the external program.

The system cannot find the file specified.

---------------------------

OK

---------------------------

This is the latest error message....any help would be appreciated..thanks!

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

well, according to that, looks like there's an extra ) at the end of the line.

another idea, does it work when you put the whole kit into the run line? what's in $variable1?

Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

Share this post


Link to post
Share on other sites

Or try:

RunWait(@comspec & ' /c start osql.exe -U sa -P master -d ' & $variable1 & ' -Q "select * from hl7patient" -o c:\hl7check.txt')

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0