Solved

Execute Telnet Commands

Posted on 2001-07-08
4
681 Views
Last Modified: 2008-03-03
Hi,

In my website I don't have telnet access.

Is there a way to execute telnet commands using php such as creating or transfering databases ?

Regards,,

0
Comment
Question by:Zuhair070699
  • 2
4 Comments
 
LVL 4

Expert Comment

by:ykf2000
ID: 6262463
Hi,


You can execute commands in PHP. Try the exec command like

exec("mylsqldump xxx > backup.txt");
0
 
LVL 1

Accepted Solution

by:
sweatje earned 50 total points
ID: 6262512
If you really wanted to be dangerous (allowing adhoc exec commands on your system is something you should try to keep to a minimum), make a form with a textbox you enter your command in as shell_command and post to this script:

<?php
exec("$shell_command", $output, $error);  
if (!$error){
     while (list(,$line) = each($output)){
       echo $line, "<BR>\n";
     }
}
?>
0
 

Author Comment

by:Zuhair070699
ID: 6264906
Hi,

I tried the following script but I got error number: 127

========================================================

<?

$shell_command= "mysql -uUserName -pPassword DatabaseName < /home/www/backup/backup.sql";

exec("$shell_command", $output, $error);  
if (!$error){
    while (list(,$line) = each($output)){
      echo $line, "<BR>\n";
    }
}

else{ echo "Error no: ";}
?>

========================================================

Any Idea
0
 
LVL 1

Expert Comment

by:sweatje
ID: 6267186
One problem is that all commands executed in this manner will be at the security level of the web server (generally nobody).  I believe nobody will have to be able to have read/execure rights on mysql and read rights on /home/www/backup/backup.sql
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now