Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2004
    Posts
    30

    Unanswered: SSH error with PHP

    i got the following error when i run a PHP script which executes ssh command.

    Code:
    Pseudo-terminal will not be allocated because stdin is not a terminal.
    May i know what is the reason for that?

    My php does the following.
    $cmd = "ssh server.com \"myscript.sh \"";
    `$cmd`

    it will print out the result of $cmd then.


    myscript.sh is a script which executes a series of ssh command.
    ssh A.com "ls -l file1",
    ssh B.com "ls -l file1",
    etc

  2. #2
    Join Date
    Jan 2004
    Location
    India
    Posts
    168
    Does your script have enough permission to execute a ssh command?
    I doubt if apache has this much permission.

    But am not sure about this. Couldyou tell me which command or function are you using to execute this script. May get a solution or idea about what to be done or waht is wronge.

    Regards
    Rajesh

  3. #3
    Join Date
    Jul 2004
    Posts
    30

    Unhappy

    my php:
    Code:
    <?php
    if(isset($_POST[btn])){
        $cmd="ssh myserver.com \"/home/myscript.sh \"";
        $cmd.=">myresultfile 2>&1";
        `$cmd`;
    }
    
    ?>
    
    <FORM NAME=testform METHOD=POST ACTION=<?php echo $_SERVER[PHP_SELF];?>>
    <textarea name=result_text rows=50 cols=100>
    <?php
        if(File_Exists("./myresultfile")){
            $fp=fopen("./myresultfile","r");
            rewind($fp);
            while(!feof($fp)){
                $fline=fgets($fp);
                print($fline);
            }
            fclose($fp);
        }
    ?>
    </textarea>
    <input type=submit name=btn value=submit>
    </form>
    myscript.sh
    Code:
    ssh myserver1.com "ls -l mydirectory/* >> lsresult";
    ssh  myserver2.com "wc -l mydatafile >> wcresult";
    if i use ssh with -t option, the problem is solved, but this time with
    Host key verification failed.

    if i take off teh -t option, i have this pseudo-terminal error..

Posting Permissions

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