00001 using System; 00002 using Str = Tamir.SharpSsh.java.String; 00003 00004 namespace Tamir.SharpSsh.jsch 00005 { 00006 /* -*-mode:java; c-basic-offset:2; -*- */ 00007 /* 00008 Copyright (c) 2002,2003,2004 ymnk, JCraft,Inc. All rights reserved. 00009 00010 Redistribution and use in source and binary forms, with or without 00011 modification, are permitted provided that the following conditions are met: 00012 00013 1. Redistributions of source code must retain the above copyright notice, 00014 this list of conditions and the following disclaimer. 00015 00016 2. Redistributions in binary form must reproduce the above copyright 00017 notice, this list of conditions and the following disclaimer in 00018 the documentation and/or other materials provided with the distribution. 00019 00020 3. The names of the authors may not be used to endorse or promote products 00021 derived from this software without specific prior written permission. 00022 00023 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00024 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00025 FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JCRAFT, 00026 INC. OR ANY CONTRIBUTORS TO THIS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT, 00027 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00029 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00030 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00031 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00032 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 */ 00034 00035 internal class RequestExec : Request 00036 { 00037 private String command=""; 00038 internal RequestExec(String foo) 00039 { 00040 this.command=foo; 00041 } 00042 public void request(Session session, Channel channel) 00043 { 00044 Packet packet=session.packet; 00045 Buffer buf=session.buf; 00046 // send 00047 // byte SSH_MSG_CHANNEL_REQUEST(98) 00048 // uint32 recipient channel 00049 // string request type // "exec" 00050 // boolean want reply // 0 00051 // string command 00052 packet.reset(); 00053 buf.putByte((byte) Session.SSH_MSG_CHANNEL_REQUEST); 00054 buf.putInt(channel.getRecipient()); 00055 buf.putString(new Str("exec").getBytes()); 00056 buf.putByte((byte)(waitForReply() ? 1 : 0)); 00057 buf.putString(new Str(command).getBytes()); 00058 session.write(packet); 00059 } 00060 public bool waitForReply(){ return false; } 00061 } 00062 }
1.5.9