サーバーサイドJavascript「Ejscript」を試してみる
リサイクルトナーを買取してもらうときの注意点
サーバーサイドでJavascriptが動くEjscriptを試してみます。Webフレームワークも豊富らしいです。これでCGIいらずになるかも?
ちなみに、
WindowsXPにインストールしよう→Cygwinがいるよ!→orz
↓
ノートPCのVMでUbuntu8.04起動→謎のエラーが出る→orz
↓
PowerPCのMac→x86コアにしてね!→orz
↓
デスクトップVMでUbuntu8.04起動→アップデートいっぱい→寝る→今
とまぁ、いろいろあってここまでこぎつけました。
インストール
http://www.ejscript.org/downloads/ejs/download.php
↑からUbuntu用のTARをダウンロードします。ダウンロードしたファイルをホームディレクトリに配置して
tar -xzvf ejs-0.9.8-8-ubuntu-LINUX-i686.tar.tar.gz
と入力して、解凍後
jigsaw@ubuntu-vm:~$ sudo ./install Embedthis Ejscript 0.9.8-8 Installation Enter requested configuration information or press <ENTER> to accept the defaults. Install binary package [Y] : y Install development headers and samples package [Y] : y Installing with this configuration: Install binary package: Y Install development doc, headers and samples package: Y Accept this configuration [Y] : y Extracting files ... tar xfz ejs-bin-0.9.8-8-ubuntu-LINUX-i686.tar.gz tar xfz ejs-dev-0.9.8-8-ubuntu-LINUX-i686.tar.gz Embedthis Ejscript installation successful.
これでインストール完了。
試す
jigsaw@ubuntu-vm:~$ ejs
ejs-0> print("Hello ejscript!!!")
Hello ejscript!!!
ejs でEjscriptのVMが起動するので、簡単にprint命令を試してみました。関数なども作れて、
ejs-0> function test(x, y) { ejs-2> return x + y ejs-2> } ejs-0> test(1, 2) 3
こんな感じでいける。セミコロンはいらないみたいです。
ejs-0> class Test { ejs-2> var width ejs-2> var height ejs-2> function Test(w, h) { ejs-3> width = w ejs-3> height = h ejs-3> } ejs-2> function setW(w) { ejs-3> width = w ejs-3> } ejs-2> } [object Type] ejs-0> t = new Test(100, 120) [object Test] ejs-0> print(t.width) 100 ejs-0> t.setW(80) ejs-0> print(t.width) 80
クラスも使えて、こんな感じで使えます。
Webフレームワークは次回!