sharedData script
暫定版だけど、とりあえずこれを使ってウェブ上にデータを残せる
立命プロキシとの格闘の末、いまいち理解してないけど、processingからネットに繋げた
後は家で設定
ruby
#!/usr/local/bin/ruby print "Content-type: text/html\n\n" ###---------------------------------------------------------------------### # Shared Data Script for Processing # modified :2010/10/28 # - Processingからフォーマットに従ったデータファイルをネットワーク上に作成します # - このスクリプトで値を書き込み、get.cgiで値を読み込みます # # -------------------- # Data Format # --------------------- # id | データの識別子 # value | 書き込む値 # --------------------- ###---------------------------------------------------------------------### # rubyをcgiプログラムにするおまじない require "cgi-lib" input = CGI.new # 変数定義 id = nil # 識別子 value = nil # 値 # 変数に値を書き込む id = input["id"] value = input["value"] # idに値が書き込まれいるか if id != nil then # value値は書き込まれているか if value != nil then # 共有ファイル作成 print "will make sharedFile." sharedFile = File.open( id + ".dat", 'w') print "sharedFile maked." # valueを書き込む sharedFile.puts value #ファイルを閉じる sharedFile.close else #valueがnilならエラー出力 print "value is nil." end else # idがnilならエラー主力 print "id is nil." end
processing
import java.net.*; import java.io.*; String urlStr = "http://www22.atpages.jp/------------/post.cgi"; String proxyStr = "proxy.ritsumei.ac.jp"; void setup(){ test(); } void draw(){ } void test(){ try{ URL url = new URL("http", proxyStr, 3128, urlStr2); URLConnection con = url.openConnection(); con.setDoOutput(true); PrintStream out = new PrintStream(con.getOutputStream()); out.print("id=toyamarinyon&value=10"); out.close(); InputStreamReader in = new InputStreamReader(con.getInputStream()); BufferedReader br = new BufferedReader(in); String line; while((line=br.readLine()) != null) { System.out.println(line); } br.close(); in.close(); } catch(IOException e){ e.printStackTrace(); } catch(Exception e){ e.printStackTrace(); } }