Jump to content

trying to run an osql statement


Recommended Posts

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"")

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Developers

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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)

Link to comment
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)

Link to comment
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)

Link to comment
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!

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

  • Developers

Or try:

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

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...