• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: | 推荐给好友 上一篇 | 下一篇

一个撤销所有系统打印请求的shell程序

发布: 2007-6-08 22:43 | 作者: seanhe | 来源: | 查看: 23次 | 进入软件测试论坛讨论

领测软件测试网
这是笔者的原创,需要的朋友请顶一下。

# 撤销所有的系统打印请求
# canall by melove 97年5月 

PRINT=`lpstat -u|wc -l`
if test $PRINT -eq 0 
   then
echo "\nSORRY! 无系统打印请求可撤销!!\n"
exit 0
fi
echo "\n正在撤销所有的系统打印请求...\c"
SHU=0
ID=`lpstat -u|awk -F " " '{print $1}'`
for lpid in $ID
   do
    cancel $lpid >/dev/null 2>&1
SHU=`expr $SHU + 1`
   done
echo "\n\nOK! 共撤销 $SHU 个系统打印请求!!\n"

 irontech 回复于:2004-07-21 15:33:21
FYI, 

   I'm not sure the script works or not. In my environment, I have local printer (use ftp printing), remote printer, hp & axis printer server printer. 

   I couldn't use normal command to cancel the print job, coz it takes quite some long time to finish or sometime couldn't cancel print Q.

   What I do is go 

/usr/spool/lp/temp & /usr/spool/lp/request delete off all files (This is for local & hp/axis printers)

/usr/spool/lp/printername delete off all files (this is for remote printer)

restart the printer services will do.

 melove 回复于:2004-07-21 17:49:09
对不住,我不是很了解你的意思。能用中文说明白吗?

 simonzhan 回复于:2004-07-21 17:59:01
[quote:1026fe090c="irontech"]FYI, 

   I'm not sure the script works or not. In my environment, I have local printer (use ftp printing), remote printer, hp & axis printer server printer. 

   I couldn't use normal command to ..........[/quote:1026fe090c]
the above script may not works for the remote printer, IMO.

 melove 回复于:2004-07-21 18:01:32
不能撤销网络打印请求。这个我倒没试过,对不住了。

 dolphinyao 回复于:2004-07-21 18:02:41
[quote:5ec0ae7df4="melove"]这是笔者的原创,需要的朋友请顶一下。

# 撤销所有的系统打印请求
# canall by melove 97年5月 

PRINT=`lpstat -u|wc -l`
if test $PRINT -eq 0 
   then
echo "\nSORRY! 无系统打印请求可撤销!!\n"
..........[/quote:5ec0ae7df4]


      很高兴看到你的SHELL,我觉得对我的帮助不小,但是我不明白的是你这个SHELL文件该怎样执行呢? 
    我的意思是比如: #sh 文件名--- 这个文件名是什么?是不是只要执行这个 sh命令就可以撤消任何打印文件了呢?
    还是执行 #canall by melove 年月日 就可以了呢?
    谢谢指点迷津!我是刚刚开始学UNIX的,也许问题比较幼稚,请你不要笑我
谢谢!

 sdccf 回复于:2004-07-21 18:04:07
不错啊,这是我的:
clear 
echo "  " 
echo "系统将要终止打印机进程"  
lpstat -u >/etc/pp  
if [ -s /etc/pp ] 
then  
list=`cat /etc/pp | awk ’{print $1}’` 
echo "请稍候......"  
for jjj in $list 
do 
cancel $jjj 
done 
else 
echo "" 
echo "\007没有打印机进程!!!"  
fi  
prompt 
read key 
}

 melove 回复于:2004-07-21 18:38:14
用vi输入我东西,并给它取一个文件名,比如 canall

然后给它执行权 chmod 755 canall 并把它放在/usr/bin/目录下

直接在提示符下 canall 就可以了。

 melove 回复于:2004-07-21 19:29:28
请问版主,可以加精吗?

 melove 回复于:2004-07-28 18:20:39
up

延伸阅读

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073

软件测试 | 领测国际ISTQBISTQB官网TMMiTMMi认证国际软件测试工程师认证领测软件测试网