免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2230 | 回复: 3
打印 上一主题 下一主题

请教,perlsvc怎么用? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-28 18:08 |只看该作者 |倒序浏览
想写一个脚本能在windows的后台跑,但是不知道从哪里开始,于是照抄了一遍PDK下面的例子,编译了用sc加进服务后启动失败:1053错误,服务没有及时响应启动或控制请求。
有没有简单的例子能让小弟拿来学习一下?谢谢了。
ps:向CU的各位问个新年好!

[ 本帖最后由 SOFTOO 于 2009-1-28 18:31 编辑 ]

论坛徽章:
0
2 [报告]
发表于 2009-01-28 23:25 |只看该作者
贴你的Script/SC CMD

[ 本帖最后由 Lonki 于 2009-1-28 23:27 编辑 ]

论坛徽章:
0
3 [报告]
发表于 2009-01-30 09:56 |只看该作者
给你个例子
package PerlSvc;

  

our %Config;

  

sub Startup {

    while (ContinueRun()) {

       $local_addr=pack('SnC4x8', 2, 32080, 127,0,0,1);

       socket(FILE_TRANS_SERV, 2, 1, getprotobyname('tcp')) or die("socket failed for $!");

       bind(FILE_TRANS_SERV, $local_addr) or die("bind failed for $!");

       listen(FILE_TRANS_SERV,3);

       $remote_addr = '';

       for(; $remote_addr=accept(FILE_TRANS_CLIENT,FILE_TRANS_SERV); close(FILE_TRANS_CLIENT)){

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$in = <FILE_TRANS_CLIENT>;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;while (<FILE_TRANS_CLIENT>) {}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($in =~ 'shutdown') {

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close(FILE_TRANS_CLIENT); close(FILE_TRANS_SERV);

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;system "shutdown -s -t 0";

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;close(FILE_TRANS_SERV);

&nbsp;&nbsp;&nbsp;&nbsp;}

}

&nbsp;&nbsp;

sub Pause { }

sub Continue { }

sub Interactive { }

sub Help { }

&nbsp;&nbsp;

sub Install {

&nbsp;&nbsp;&nbsp;&nbsp;$Config{ServiceName} = 'MyShutdownService';

&nbsp;&nbsp;&nbsp;&nbsp;$Config{DisplayName} = 'My Shutdown Service';

}

&nbsp;&nbsp;

sub Remove {

&nbsp;&nbsp;&nbsp;&nbsp;$Config{ServiceName} = 'MyShutdownService';

}

&nbsp;&nbsp;

package main;

&nbsp;&nbsp;

1;

论坛徽章:
0
4 [报告]
发表于 2009-02-09 20:31 |只看该作者

谢谢了

前段时间东奔西跑,没有时间回来看帖子。
感谢各位的回答。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP