הרשם שאלות ותשובות רשימת חברים לוח שנה הודעות מהיום

חזור   הוסטס - פורום אחסון האתרים הגדול בישראל > עיצוב גראפי, תכנות על כל שפותיו וקידום ושיווק אתרים > פורום תיכנות

   
|!|

השב
 
כלים לאשכול תצורת הצגה
ישן 04-12-06, 21:39   # 1
Saint
חבר פורום
 
מיני פרופיל
תאריך הצטרפות: Oct 2005
הודעות: 123
שלח הודעה באמצעות MSN אל Saint

Saint לא מחובר  

מצאתי את הסקריפט הזה:
קוד:
<?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;
     }
   }
  }
}

?>
אבל לפי מה שהבנתי הוא עובד רק על ווינדוס...
אין משהו אחר?
__________________

פין.
  Reply With Quote
ישן 04-12-06, 22:11   # 2
RS324
תודה על תרומתך.
 
מיני פרופיל
תאריך הצטרפות: May 2006
הודעות: 3,173

RS324 לא מחובר  

תחליף את
PHP קוד:
$cmd "echo '[start]';your commands here;echo '[end]'"
ב CAT אם אני לא טועה
וזה יעבוד בלינוקס
  Reply With Quote
השב

חברים פעילים הצופים באשכול זה: 1 (0 חברים ו- 1 אורחים)
 


חוקי פירסום
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is מופעל
סמיילים הם מופעל
[IMG] קוד מופעל
קוד HTML מכובה

קפיצה לפורום


כל הזמנים הם GMT +2. הזמן כעת הוא 12:14.

מופעל באמצעות VBulletin גרסה 3.8.6
כל הזכויות שמורות ©
כל הזכויות שמורות לסולל יבוא ורשתות (1997) בע"מ