Forum Discussion

joffre's avatar
joffre
Regular Contributor
15 years ago

Wait for a command to continue executing

Hi all.



I need to make the code below, wait until the "EXIT " is informed to move to the next line of code.

I am using "Call Delay" but it isn't resolving, since not all commands invoked take the same amount.



Call TestedApps.cmd.Run(1, True) 'open the Command Prompt

Call Aliases.cmd.wndConsoleWindowClass.Keys(ComandoCriarTabela&"2.Nucleo\SQLServer\1.sql[Enter]Exit[Enter]")

Call Delay(5000)



Here are the variable declaration for your knowledge:

ComandoCriarTabela = "sqlcmd -S " &Servidor& " -d " &Database& " -U " &Usuario& " -P " &Senha& " -i " &Caminho&""

Servidor = "srv-tsbd\sql2k"

Database = "TS_F_SQL2K_20112"

Usuario = "homol"

Senha = "tssql2k"

Caminho = "D:\Scripts\Scripts_Criacao_Banco\"



It is working fine. The command is correct. I just need a solution for my problem. How to make my code wait until EXIT is informed?



Hope someone can help me.



Thanks.

36 Replies

  • joffre's avatar
    joffre
    Regular Contributor
    Here I am again.



    Robert, thanks for your time.



    Your idea worked. But how will I close this sqlplus process to go to the other script line?



    I did this way:
    Funcao(Acesso&"\1.LGComponentes\Oracle\1.sql"), where Acesso = "sqlplus TS_F_ORA9_EFGH/dev@srv-tsbd-9i @D:\Scripts\Scripts_Ora9i".



    Hope you can help.
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Does SQLPlus not automatically exit after executing the SQL query?  I would expect it does it if has command line parameters.



    You'll need to research within the SQLPlus user documentation to find the correct syntax and commands within SQL Plus to do what you want to.  Once you have that figured out, the method you've coded to use will work well.
  • joffre's avatar
    joffre
    Regular Contributor
    Sadly, it doesn't.

    After finish the sql script, it waits another command. If I type "EXIT", it will close (attached). I'm trying on Oracle's forums if anyone know how to do everything in one line.



    If someone here find anything about it, please, let me know.
  • joffre's avatar
    joffre
    Regular Contributor
    Hi friends.



    I found a way to make everything I need in just one line.



    sqlplus TS_F_ORA9_JOFFRE/dev@srv-tsbd-9i @D:\Scripts\Scripts_Ora9i\1.LGComponentes\Oracle\1.sql > D:\Scripts\Logs9i\1-1.txt




    The problem now is that the part responsible for my log creation isn't being readed by TestComplete (I think). The script is executed, the output inside the command prompt is shown, but the log that should be created inside D:\Scripts\Logs9i isn't created.



    Any ideas?
  • joffre's avatar
    joffre
    Regular Contributor
    sqlplus TS_F_ORA9_JOFFRE/dev@srv-tsbd-9i @D:\Scripts\Scripts_Ora9i\1.LGComponentes\Oracle\1.sql > D:\Scripts\Logs9i\1-1.txt




    I think the Function that you guys wrote for me isn't accepting spaces after the "1.sql".

    On my log message the code line is correct, but I think TestComplete isn't reading the entire line to execute it.



    Any idea about how I'll make it work?

  • Hi Joffre,





    The problem now is that the part responsible for my log creation isn't being readed by TestComplete (I think).


    Is there a difference if you run your command using the Funcao function and using cmd.exe? If not, this means that you'll need to review the command. Otherwise, please post a few images demonstrating the difference.