Skip to content

Instantly share code, notes, and snippets.

@ttoz
Created March 24, 2012 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ttoz/2184868 to your computer and use it in GitHub Desktop.
Save ttoz/2184868 to your computer and use it in GitHub Desktop.
Windows版Eclipseのコンソールウィンドウをコマンドプロンプトとして活用するための外部ツール用PHPスクリプト
<?php
/**
* Input to eclipse's console view window
*
* Run > External Tools > External Tools configurations...
* Name cmd
* Maintab's Location C:\path\to\php.exe
* Maintab's Working Directory ${workspace_loc:/your_project}
* Maintab's Arguments C:\path\to\cmd.php
* click external tool button to run
*/
define('EXE', 'C:\path\to\php.exe');
$fp = fopen('php://stdin', 'rb');
if(!$fp) exit;
$loop = true;
do {
$line = fread($fp, 1024);
if (strlen($line) == 0) break;
if ($line == 'exit' . PHP_EOL) $loop = false;
$res = null;
exec(preg_replace('/^php/', EXE, $line), $res);
echo join(PHP_EOL, $res) . PHP_EOL;
} while($loop);
fclose($fp);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment