|
|
# 1 |
|
חבר פורום
|
שאלה בקשר לSSH
אני רוצה לבנות סקריפט בPHP שדרכו אני יוכל להתקין שרתי TeamSpeak וכל מיני...
עכשיו אני צריך איזה מדריך שיעזור לי ללמוד על עבודה עם SSH ו PHP בנושא שציינתי מקודם. תודה מראש.
__________________
פין. |
|
|
|
# 2 |
|
תודה על תרומתך.
|
|
|
|
|
# 3 |
|
חבר פורום
|
מצאתי את הסקריפט הזה:
קוד:
<?php
$ip = 'ip_address';
$user = 'username';
$pass = 'password';
$connection = ssh2_connection($ip);
ssh2_auth_password($connection,$user,$pass);
$shell = ssh2_shell($connection,"bash");
//Trick is in the start and end echos which can be executed in both *nix and windows systems.
//Do add 'cmd /C' to the start of $cmd if on a windows system.
$cmd = "echo '[start]';your commands here;echo '[end]'";
$output = user_exec($shell,$cmd);
fclose($shell);
function user_exec($shell,$cmd) {
fwrite($shell,$cmd . "\n");
$output = "";
$start = false;
$start_time = time();
$max_time = 2; //time in seconds
while(((time()-$start_time) < $max_time)) {
$line = fgets($shell);
if(!strstr($line,$cmd)) {
if(preg_match('/\[start\]/',$line)) {
$start = true;
}elseif(preg_match('/\[end\]/',$line)) {
return $output;
}elseif($start){
$output[] = $line;
}
}
}
}
?>
אין משהו אחר?
__________________
פין. |
|
|
|
# 4 |
|
תודה על תרומתך.
|
תחליף את
PHP קוד:
וזה יעבוד בלינוקס |
|
|
|
# 5 |
|
מתאורר / יצא בחוץ
|
הפקודה ש Saint הביא תעבוד גם על לינוקס רק כשמותקן המודל SSH2 לPHP
|
|
|
|
# 6 |
|
חבר פורום
|
אההה.. איך אני מתקין את המודל הזה?
__________________
פין. |
|
|
|
# 7 |
|
מתאורר / יצא בחוץ
|
http://il2.php.net/ssh
יש פה מדריך |
|
![]() |
| חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים) | |
|
|