[Prev] [Menu] [Next]

How to start/stop Pgbash


  • Interactive environment

    When starting Pgbash as a sub shell in the interactive environment, please type '/usr/local/bin/pgbash' after log-in. The next Welcome message is displayed when Pgbash starts.

      prompt> /usr/local/bin/pgbash
      Welcome to Pgbash version x.x ( bash-x.x.x )
    
        Type '?' for HELP.
        Type 'connect to DB;' before executing SQL.
        Type 'SQL;' to execute SQL.
        Type 'exit' or 'Ctrl+D' to terminate Pgbash.
    
      pgbash> exit
    

    When stopping Pgbash, please type 'exit' (or Ctrl+D). Pgbash stops and you go back to the log-in shell.

    In the interactive environment, Pgbash reads ~/.bashrc and ~/.pgbashrc. If ~/.pgbashrc does not exist, Pgbash reads /etc/pgbashrc. If you changed pgbashrc, please type 'source' command.

    pgbash> source file_name (ex. source /etc/pgbashrc)

  • Shell script

    If you want to start Pgbash as a shell script:

    1. Create a shell script using editor.
    2. chmod +x shell_script_file
    3. Execute a shell script.

    Pgbash will stop when a shell script stops.

    You must describe "#!/usr/local/bin/pgbash" at the top of a shell script. In addition, When starting Pgbash as a shell script, Pgbash doesn't read a bashrc and a Pgbashrc automatically. If you want to usr a Pgbashrc , you must describe 'source' command.

    #!/usr/local/bin/pgbash
    source /etc/pgbashrc ............ If you want to read,..
    #

    (Attention)
    A new line code of a shel script is LF code. It is not CR+LF code.

  • CGI (Web application)

    CGIiWeb application) is a sort of a shell script too. However, it is different from a general shell script that it is started from a Web server. Pgbash is started as follows.

    1. Create CGI using editor.
    2. Copy CGI to the cgi-bin directory.
    3. chmod +x CGI_file
    4. Execute CGI from a FORM statement of HTML.

    You must describe some commands as follows at the top of CGI.

    #!/usr/local/bin/pgbash 
    exec 2>&1   .............................display bash error messages.
    echo "Content-type: text/html" ..........Indispensable
    echo ""   ...............................Indispensable
    set EXEC_SQL_OPTION CGI; ................Indispensable(Change CGI mode)
    source /etc/pgbashrc  .................. optional
    

    * 'exec 2>1' is a command for displaying bash error messages.
    * "Content-type:text/html" and " " is required for CGI program.
    * 'set EXEC_SQL_OPTION' stores data of homepage in shell variables.

[Prev] [Menu] [Next]