Call Shell in Forms 10g

Dicas do Oracle Forms Builder - Blocos, Itens, LOV, Canvas, Triggers, comandos, PLL, d2kwutil, FMB, Alert, menus, etc
Post Reply
s_feitoza
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 10
Joined: Thu, 29 Nov 2007 5:04 pm
Location: São Paulo

Good morning everyone ..

I am using Forms 10G and prescission call some shells that is on the server. I tried to use the host command plus the same so makes the form giving loop and has nothing ... I can call the other form and the reports ...
My question is how I should call these shells ...

grateful from silvio
User avatar
dr_gori
Moderador
Moderador
Posts: 5026
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Search for Package Daemon .
She runs things on the server. (Unfortunately, I do not have her here)
: -O
User avatar
dr_gori
Moderador
Moderador
Posts: 5026
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

Yes I have!
Here she, I just do not know if it's just compiling and it will work. Maybe you have to have some file on the server.

Spec

Select all

create or replace package daemon as 
  /* Executes a non-query sql statement or plsql block.  Arguments: 
     command: the sql statement to execute 
     timeout: (optional) number of seconds to wait to send or receive a 
              message 
     Returns the sqlcode after execution of the statement. */ 
  function execute_sql(command varchar2, timeout number default 10) 
    return number; 
 
  /* Executes a system (host) command.  Arguments: 
     command: the command to execute 
     timeout: (optional) number of seconds to wait to send or receive a 
              message 
     Returns the value passed to the operating system by the command. */ 
  function execute_system(command varchar2, timeout number default 10) 
    return number; 
 
  /* Tells the daemon listener to exit.  Arguments: 
     timeout: (optional) number of seconds to wait to send the message. */ 
  procedure stop(timeout number default 10); 
end daemon;
Body

Select all

create or replace package body daemon as 
 
  function execute_system(command varchar2, timeout number default 10) 
    return number is 
 
    s number; 
    result varchar2(20); 
    command_code number; 
    pipe_name varchar2(30); 
  begin 
 
    /* Use uniqe_session_name to generate a unique name for the return pipe. 
       We include this as part of the inital message to the daemon, and it is 
       send along the pipe named 'daemon'.  */ 
    pipe_name := dbms_pipe.unique_session_name; 
 
    /* Send the 'SYSTEM' command to the daemon. */ 
    dbms_pipe.pack_message('SYSTEM'); 
    dbms_pipe.pack_message(pipe_name); 
    dbms_pipe.pack_message('export GTA=/usr/Gta;'||command); 
    s := dbms_pipe.send_message('daemon', timeout); 
    if s <> 0 then 
      raise_application_error(-20010, 
        'Execute_system: Error while sending.  Status = ' || s); 
    end if; 
 
    /* Check for the handshake message.  Note that we are now listening on 
       the pipe which is unique to this session. */ 
    s := dbms_pipe.receive_message(pipe_name, timeout); 
    if s <> 0 then 
      raise_application_error(-20011, 
        'Execute_system: Error while receiving.  Status = ' || s); 
    end if; 
 
    /* Get the operating system result code, and display it using 
       dbms_output.put_line(). */ 
    dbms_pipe.unpack_message(result); 
    if result <> 'done' then 
      raise_application_error(-20012, 
        'Execute_system: Done not received.'); 
    end if; 
 
    dbms_pipe.unpack_message(command_code); 
    dbms_output.disable; 
    dbms_output.enable(1000000000); 
    dbms_output.put_line('System command executed.  result = ' || 
                         command_code); 
    return command_code; 
  end execute_system; 
 
 
  function execute_sql(command varchar2, timeout number default 10) 
    return number is 
 
    s number; 
    result varchar2(20); 
    command_code number; 
    pipe_name varchar2(30); 
  begin 
 
 
    /* Use uniqe_session_name to generate a unique name for the return pipe. 
       We include this as part of the inital message to the daemon, and it is 
       send along the pipe named 'daemon'.  */ 
    pipe_name := dbms_pipe.unique_session_name; 
 
    /* Send the 'SQL' command to the daemon. */ 
    dbms_pipe.pack_message('SQL'); 
    dbms_pipe.pack_message(pipe_name); 
    dbms_pipe.pack_message('export GTA=/usr/Gta;'||command); 
    s := dbms_pipe.send_message('daemon', timeout); 
    if s <> 0 then 
      raise_application_error(-20020, 
        'Execute_sql: Error while sending.  Status = ' || s); 
    end if; 
 
    /* Check for the handshake message.  Note that we are now listening on 
       the pipe which is unique to this session. */ 
    s := dbms_pipe.receive_message(pipe_name, timeout); 
    if s <> 0 then 
      raise_application_error(-20021, 
        'Execute_sql: Error while receiving.  Status = ' || s); 
    end if; 
 
    /* Get the result code from the SQL statement, and display it using 
       dbms_output.put_line(). */ 
    dbms_pipe.unpack_message(result); 
    if result <> 'done' then 
      raise_application_error(-20022, 
        'Execute_sql: Done not received.'); 
    end if; 
 
    dbms_pipe.unpack_message(command_code); 
    dbms_output.put_line('SQL command executed.  sqlcode = ' || command_code); 
    return command_code; 
  end execute_sql; 
 
 
  procedure stop(timeout number default 10) is 
    s number; 
  begin 
 
    /* Send the 'STOP' command to the daemon. */ 
    dbms_pipe.pack_message('STOP'); 
    s := dbms_pipe.send_message('daemon', timeout); 
    if s <> 0 then 
      raise_application_error(-20030, 
        'Stop: Error while sending.  Status = ' || s); 
    end if; 
  end stop; 
 
end daemon;

An example of the Its use:
(in this case, send an email by shell)

Select all

declare 
  ln_daemon number; 
begin 
 
  ln_daemon := daemon.execute_system('echo "Ocorreu ERRO na Importação das Faturas! Veja tabela LOG_FATURA!" | mail -s $(hostname)_LOGFATURA bill@microsoft.com'  ,10000 ); 
end;
s_feitoza
Rank: Estagiário Sênior
Rank: Estagiário Sênior
Posts: 10
Joined: Thu, 29 Nov 2007 5:04 pm
Location: São Paulo

Hi, good afternoon ... I tried error ...

I create this package in the forms or at the bank? For the forms does not accept some PL / SQL expressions

Replace for example ...

Remembering that I am with 10G forms and accessing a Linux server to run commands In shells ...
User avatar
dr_gori
Moderador
Moderador
Posts: 5026
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

It's a bank package!
It runs things on the operating system where Oracle is installed!
gokden
Rank: DBA Pleno
Rank: DBA Pleno
Posts: 264
Joined: Sun, 19 Aug 2007 8:18 pm
Location: Ribeirão Preto - SP
Lucas de Souza

OCA Developer
Analista de sistemas

Galera .... to with a mistake so at the time of running this package.

Select all

ERROR at line 1: 
ORA-20011: Execute_system: Error while receiving.  Status = 1 
ORA-06512: at "LUCAS.DAEMON", line 61 
ORA-06512: at line 1 
Someone knows why ??
facc
Rank: Analista Pleno
Rank: Analista Pleno
Posts: 104
Joined: Wed, 27 May 2009 2:37 pm
Location: Cerquilho / SP

Sorry to raise this topic, but I'm having the same mistake with this package
Petermann
Rank: Programador Júnior
Rank: Programador Júnior
Posts: 18
Joined: Mon, 26 Jan 2009 2:26 pm
Location: Brusque - SC
Alexandre Petermann

Some know here what parameters are to run the package code daemon , for the following code:

Select all

  PROCEDURE EXPORTA_DELPHI IS 
   
    ln_daemon number; 
  begin 
   
    ln_daemon := daemon.execute_system(I:\click_Textil\ceja\Delphi\Delphi_Exportaçao_Dados\P_CEJA.exe); 
   
  end;
User avatar
dr_gori
Moderador
Moderador
Posts: 5026
Joined: Mon, 03 May 2004 3:08 pm
Location: Portland, OR USA
Contact:
Thomas F. G

Você já respondeu a dúvida de alguém hoje?
https://glufke.net/oracle/search.php?search_id=unanswered

You must also put the timeout: (in the example below, 10000)

Select all

declare 
  ln_daemon number; 
begin 
 
  ln_daemon := daemon.execute_system('echo "Ocorreu ERRO na Importação das Faturas! Veja tabela LOG_FATURA!" | mail -s $(hostname)_LOGFATURA bill@microsoft.com'  ,10000 ); 
end;
But remember that it runs on the Oracle server, not on the local user machine.
Luctly
Rank: Estagiário Júnior
Rank: Estagiário Júnior
Posts: 2
Joined: Thu, 17 Oct 2024 10:19 pm
Location: Brazil

Topic under translation. Come back later. (This is an automatic message)
Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest