[转贴]用Delphi在客户端执行Unix主机命令
来源:互联网
作者:west263.com
时间:2008-04-16
西部数码-全国虚拟主机10强!40余项虚拟主机管理功能,全国领先!双线多线虚拟主机南北访问畅通无阻!免费赠送企业邮局,.CN域名,自助建站480元起,免费试用7天,满意再付款! P4主机租用799元/月.月付免压金!
m_string:=m_string+ch;
end;
m_count:=m_count+1;
end;
//假设编程者知道Unix的LOGIN和PASSWORD
if(Length(m_string)>0) then
begin
while ((Pos(‘login:',m_string)>0)and(not
loginsend)) do
begin
cmdtounix:=‘root'+#10+#13;
code:=Socket.SendBuf(cmdtounix,6);
loginsend:=True;
end;
while ((Pos(‘Password:',m_string)>0)and(not passsend)) do
begin
cmdtounix:=‘root'+#13+#10;
code:=Socket.SendBuf(cmdtounix,6);
passsend:=True;
m_string:=‘';
end;
if ( Pos(‘jcy:/#>',m_string)>0) then
begin
cmdtounix:=‘mkdir /tmp/fang'+#
13+#10;
code:=Socket.SendBuf(cmdtounix,
Length(cmdtounix));
if code>0 then
begin
ClientSocket1.Active:=False;
Close;
end;
end;
end;
end;
end;
小 结
虽然这段程式并不复杂,但他是网络软件编程的一个基本思路。需要指出的是,在某些场合,程式员也能够根据自己的需要定义一些协议,以便解决问题。当然,自己定义的协议应用范围可能会很窄,只能在某个系统或程式中使用。
[/code:1:779cf827c6][/code]




