FreshMint Posted July 15, 2008 Share Posted July 15, 2008 Okay here's what I'm doing - I'm trying to get this php page to connect to a Unix box and (an ESX box) and execute some commands. It connects fine, and even executes SOME commands just fine. Heres the code: <?php $doit = "vim-cmd vmsvc/getallvms" ; $connection = ssh2_connect('192.168.10.9', 22); ssh2_auth_password($connection, 'root', 'mysecret'); $cmd = shell_exec($doit) if ($cmd){echo('pass <br><br>');} else{echo('fail<br><br>');} echo ($cmd); ?> Now that if statement is solely to see if the commands are being executed. Now If I put $doit to a normal 'ls -lart' or something similar (a standard command) it works fine with the shell_exec. and returns the PASS and echos the entire CMD return for ls However if I try to use the ESX command vim-cmd vmsvc/getallvms - it fails and nothing returns. I've also tried putting my vim-cmd command into a shell script and setting $dir = "bash vimon.sh" $dir = "./vimon.sh" $dir = "sh vimon.sh" None of those work either. Now, also if i use the ssh2_exec function it returns "Resource id #3" and "PASS" But no matter what command is executes it always returns that "Resource id #3" - even the LS doesnt work when i use that function. Also its worth noting that if I manually SSH through a terminal I can execute all these commands just fine. Thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.