[Wtr-general] manipulating dos prompt with watir
Bret Pettichord
bret at pettichord.com
Tue May 1 12:22:15 EDT 2007
alan wrote:
> In my watir script i would like to have it go to open a dos command window and start sqlplus, then run a simple query to see if a member exists, the flow would be something like:
> open cmd.exe
> log in as name at data09
> pass the password somewhere around here
> do query select * from members where name = 'testername'
> if cmd contains(testername)
> puts 'yay'
> else
> puts 'drat'
> end
>
> is this easily done? so far after spending most of the day in google and trying some different ideas I still have nothing. suggestions?
> i'm new to sql and watir, but since i did make watir send results to and excel file I figure this must also be doable.
>
You should use Ruby's system command to directly call sqlplus and put
your commands in a file that is then passed as an argument to sqlplus.
You will need to refer to the sqlplus command line documentation for
details on how to do this.
I am currently using this approach to run scripts using sqlcmd, which is
the SQL Server corolate to Oracle's sqlplus.
Some other people have suggested other methods for accessing a database,
which you may also want to experiment with, but this approach will
probably be the easiest for you.
Bret
More information about the Wtr-general
mailing list