Executing Scripts from PHP Web Interface


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Executing Scripts from PHP Web Interface
# 1  
Old 03-03-2011
Executing Scripts from PHP Web Interface

Later Edit: So far the problem is solved, i've loaded the .profile into the bash script, and now it's working great
But I might have some future questions, so please don't close the thread. Thanks


Hello everyone,

I am trying to develop an web interface, which is able to execute pre-defined sh scripts and display the output in the interface.

Unfortunetely I am not able to execute the script files.
If I execute the script inside the console it works, but if I execute it from PHP the script won't do anything.

I installed ssh2 extension for PHP and here is my code (it's just a basic one)

PHP Code:
if(!($con ssh2_connect("server"22))){
echo 
"<br/>";
echo 
"fail: unable to establish connection\n";

} else {



if(!
ssh2_auth_password($con"user""password")) {

echo 
"fail: unable to authenticate\n";

} else {



echo 
"Logged In\n";

// execute a command

if(!($stream ssh2_exec($con"./report" )) ){

echo 
"Unable to execute\n";

} else{

// collect data


stream_set_blocking$streamtrue );

$data "";

while( 
$buf fread($stream,4096) ){

$data .= $buf;

echo .
$buf;

}

fclose($stream);

}

}

}

?> 
Thanks In Advance

Last edited by SuperDuck; 03-03-2011 at 09:48 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Web Interface for shell script.

Hi Team, I have daily pdf files which i have to convert in tif images. I have script which does it. I need to put these images in some specific folder (which i create manually) on server. Is there any web based way to it, so that user can simply browse file & it will convert & upload on... (1 Reply)
Discussion started by: paragnehete
1 Replies

2. Web Development

Web Interface for a database

Hi Gents, What is the best way to create a web interface for mysql database? That I can manage my data for root user and for normal user as well according to their privileges? Assuming that I use Linux as a server and Apache as a web server and my database is mysql. Thanks in advance (5 Replies)
Discussion started by: leo_ultra_leo
5 Replies

3. Web Development

Need to run Nagios Web Interface on a different port

Hi, During Nagios install we added the following piece of config to apache httpd.conf file and it runs on the regular port 80, now if I want to run this on a different port then what needs to changed to make it run on lets say port 8080. I tried adding Virtual servers but was getting... (1 Reply)
Discussion started by: jacki
1 Replies

4. Web Development

Editing a conf file via web interface

hello all, i have completed an installation of squid proxy. i want a web editor that will allow me to edit only a single conf file..coz i dont want to give the user access via terminal. the user is restricted only to this file. also, once he/she has modified the file, i want to run the... (1 Reply)
Discussion started by: coolatt
1 Replies

5. Web Development

web interface to view,copy,select files

Hi. I have been working on an email backup solution. I need some kind of web admin interface to view , copy & select files in order to restore them. Can someone point me to the right direction? Or do i need to code it from scratch. Something that need a little modification to work is OK. ... (3 Replies)
Discussion started by: coolatt
3 Replies

6. Shell Programming and Scripting

navigating a web interface with a shell script

I'm trying to design a script that will check the external ip address of my home network and then assign it to the A record of a subdomain. When i started, i thought i could do this with SSH, but turns out I don't have ssh access to update the DNS record (not surprising i suppose) So now, i... (2 Replies)
Discussion started by: boyincity
2 Replies

7. Infrastructure Monitoring

Nagios web interface is not getting

Hello everyone, I had installed nagios 3 on fedora 5 successfully and i have verified sample config file by issueing command like /usr/local/..... -v /usr/local.../nagios.cfg . ....and i am getting the result as well. After that i started nagios by giving command like ... service nagios... (1 Reply)
Discussion started by: Renjesh
1 Replies
Login or Register to Ask a Question