Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2003
    Location
    India
    Posts
    14

    Unanswered: Problem with my PHP code

    Hi friends
    I created a webpage thru which i executed Db2 commands using
    System function available in PHP.I created an instance which i set it to the
    environment variable .Now when i try to create a sample Database i get the
    error "SYSTEM" does not have the authority to perform the requested
    command".I am able to do all these functions thru normal DB2CLP but unable
    to achieve these tasks thru webpage.Can anyone help me to solve this
    problem at the earliest?I have attached the code below which could be helpful for u to find
    a solution.Thanx in advance.bye
    Thanks and regards
    Sriram

    <?php //Start of PHP
    session_start(); //Staring a SESSION
    $_SESSION['instance']=$_POST[instance];
    $_SESSION['Login']=$_POST[Login];
    $_SESSION['pwd']=$_POST[pwd];
    $instance=$_SESSION['instance'];
    $Login=$_SESSION['Login'];
    $pwd=$_SESSION['pwd'];

    $instance contains the instance name obtained from the previous page in a
    form
    //ly $login and $pwd contains the domain username and password

    system('db2stop'); //Stopping the current instance if any

    $ins="db2icrt ".$instance; Eg Instance name is:::"newinst"
    system($ins); //Executing $ins

    echo "<BR>Instance ($instance) created succseefully";
    prints::Instance (newinst) created succseefully

    putenv("db2instance=$instance"); Setting the current instance to env
    variable

    system('db2cmd /c /w /i db2 get instance');
    Prints ::The current database manager instance is: NEWINST

    $att="db2cmd /c /w /i db2 attach to ".$instance." USER ".$Login." USING
    ".$pwd; //Attach the instance
    system($att);

    system('db2start');
    Prints::
    SQL5043N Support for one or more communications protocols failed to start
    successfully. However, core database manager functionality started
    successfully.

    system('db2sampl');
    Prints::
    SQL1092N "SYSTEM" does not have the authority to perform the requested
    command

    //I need to create sample db only .My prj works around this databse

    session_write_close();


    ?> //End of PHP

  2. #2
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    20
    Is the HTTP-Server running with the same user as the user owns the instance. Root also get this message if he tries to start or shutdown a database, only the user db2inst1(owner of db2inst1) is capable of executing these commands.

    There is no suexec for mod_php4, but if you execute some special php-Scripts as CGI and suexec you might be able to run the db2 commands.

    Maybe it also works if you write a wrapper which executes the commands via sudo and the owner of the instace you want to send commands

    Greetings Jürgen

  3. #3
    Join Date
    Apr 2003
    Location
    India
    Posts
    14

    Re-Problem with PHP code

    Hi
    HTTP Server is running in my system where instance is created.I use WinNT,Apache server 3.x ,PHP 4.1 and DB2UDB7.1.I use apache module not CGI.I like to know what is sudo and how can i create wrapper which executes the db2commands thru sudo.If possible pls provide me the coding part bcause i have not created a wrapper previously.I execute the db2 commands under my domain which has got full authority .It is surprising that i am able to perform all the operations through Command line which im unable to achieve through a webpage.The only task which is left over in my prj is creating a sample database.So pls help me to succesfully complete the task.Any queries pls Revert me back.Thanx in advance.Bye
    With warm regards
    VRAM





    Originally posted by hernst
    Is the HTTP-Server running with the same user as the user owns the instance. Root also get this message if he tries to start or shutdown a database, only the user db2inst1(owner of db2inst1) is capable of executing these commands.

    There is no suexec for mod_php4, but if you execute some special php-Scripts as CGI and suexec you might be able to run the db2 commands.

    Maybe it also works if you write a wrapper which executes the commands via sudo and the owner of the instace you want to send commands

    Greetings Jürgen

  4. #4
    Join Date
    Feb 2003
    Location
    Germany
    Posts
    20

    Re: Re-Problem with PHP code

    Originally posted by vram
    HTTP Server is running in my system where instance is created.I use WinNT,Apache server 3.x ,PHP 4.1 and DB2UDB7.1.
    In your first post you didn't mention that it is a windows system and so i assumed it's on Unix/Linux where sudo is available. Under Windows I don't know something like sudo. It's a Unix command to execute commands as a different user.

    Why your script is not working under Windows I don't know.

    Greetings Jürgen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •