summaryrefslogtreecommitdiff
path: root/app/controllers/commands_controller.rb
blob: e8c8adadd32e76333fe796904427ea9831240c6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
class CommandsController < ApplicationController
  # GET /commands
  # GET /commands.xml
  def index
    @commands = Command.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @commands }
    end
  end

  # GET /commands/1
  # GET /commands/1.xml
  def show
    @command = Command.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @command }
    end
  end

  # GET /commands/new
  # GET /commands/new.xml
  def new
    @command = Command.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @command }
    end
  end

  # GET /commands/1/edit
  def edit
    @command = Command.find(params[:id])
  end

  # POST /commands
  # POST /commands.xml
  def create
    @command = Command.new(params[:command])

    respond_to do |format|
      if @command.save
        format.html { redirect_to(@command, :notice => 'Command was successfully created.') }
        format.xml  { render :xml => @command, :status => :created, :location => @command }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @command.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /commands/1
  # PUT /commands/1.xml
  def update
    @command = Command.find(params[:id])

    respond_to do |format|
      if @command.update_attributes(params[:command])
        format.html { redirect_to(@command, :notice => 'Command was successfully updated.') }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @command.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /commands/1
  # DELETE /commands/1.xml
  def destroy
    @command = Command.find(params[:id])
    @command.destroy

    respond_to do |format|
      format.html { redirect_to(commands_url) }
      format.xml  { head :ok }
    end
  end
  
  def conn
    Net::SSH.start( '127.0.0.1', 'unf-ubu' ) do |session|
      session.open_channel do |channel|
        channel.on_close do |ch|
          puts "channel closed successfully."
          render :text => 'hits'
        end
        puts "closing channel..."
        channel.close
      end
      session.loop
    end   
  end




  
  
end