📄 remoteshellclient.java
字号:
import java.net.*;
import java.io.*;
import java.util.*;
class RemoteShellClient
{
public static void main (String[] args)
{
if(args.length==4)
{
int nPort = new Integer(args[1]).intValue();
if(nPort>0)
{
try
{
// connect to the given server at the given port
Socket sockClient = new Socket(args[0],nPort);
// open input and output streams to the server
BufferedOutputStream outStream = new BufferedOutputStream(sockClient.getOutputStream());
BufferedInputStream inStream = new BufferedInputStream(sockClient.getInputStream());
// send the command to the server
SockData.Write(outStream,args[2].getBytes(),args[2].length());
// send the input of the command to the server
SockData.Write(outStream,args[3].getBytes(),args[3].length());
// read output from the server and display
// the output in the console window
while(true)
{
byte[] pOutput = SockData.Read(inStream);
if(pOutput.length>0)
{
System.out.write(pOutput);
}
else break;
}
SockData.Write(outStream,null,0);
// clean up
inStream.close();
outStream.close();
sockClient.close();
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
else System.out.println("Invalide port number");
}
else System.out.println("Invalide argument count");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -