python批量启动关闭程序

#!/usr/bin/env python
#coding:utf-8

import os
import re
import sys

script_name = sys.argv[0]
game_gen_path = ‘/data/bz-tw-and‘
def callable(input_args):
for (root,dirs,filename) in os.walk(game_gen_path):
for file in filename:
if re.match(input_args,file):
script_abs_path=os.path.join(root,file)
os.system(‘sh %s‘ % script_abs_path)
if re.match(input_args,‘status‘):
os.system(‘ps aux | grep bz-tw-and-s | grep -v grep‘)
try:
input_args = sys.argv[1]
except IndexError as e:
print(e)
print(‘Example: python %s start|stop|status‘ % script_name )
else:
callable(input_args)

原文地址:http://blog.51cto.com/yht1990/2133082

时间: 2024-08-11 05:34:48

python批量启动关闭程序的相关文章

PowerShell批量启动/关闭Azure VM

备注:以下例子中出现的JohnsonWeb, JohnsonVm均是虚拟机的名称.在运行Powershell脚本之前,请导入您的订阅文件. 根据条件启动/关闭虚拟机,例如根据虚拟机名称,批量启动/关闭 启动虚拟机 $vmNames = New-Object System.Collections.ArrayList $vmNames.Add("JohnsonWeb") $vmNames.Add("JohnsonVm") foreach($vm in Get-Azure

新装python环境启动django程序报错

个人独立博客 http://www.xbman.cn/ 出处:http://www.xbman.cn/article/1 django启动报错 django.core.exceptions.ImproperlyConfigured: Error loading either pysqlite2 or sqlite3 modules (tried in that order): No module named _sqlite3 解决方法 centos yum install python-deve

linux 开机批量启动程序

每天早上到公司第一件事打开电脑,打开我的qq,我的开发工具idea,在看看邮件,日复一日,变懒了,也变聪明了,写了下面一段脚本 文件名:mystart.sh #!bin/bash #检验我的开发工具是否已经启动,如果没有启动,启动程序,并在终端打印简单启动信息 ideaNum=`ps -ef | grep idea | awk '{print $2}' | wc -l` flag=2 if [ $ideaNum -lt $flag ];then nohup sh /home/wangjun/so

python批量同步web服务器代码核心程序

#!/usr/bin/env python #coding:utf8 import os,sys import md5,tab from mysql_co.my_db import set_mysql from ssh_co.ssh_connect import sshd from ssh_co.cfg.config import ssh_message,item_path from file import findfile def my_mysql(): db_file={} my_conne

在春天结束JVM当浏览器选项卡关闭启动应用程序

我有一个spring-boot web应用程序分配jar文件. 启动应用程序的代码如下: private static ConfigurableApplicationContext ctx; public static void main(String[] args){ if(ctx == null) { ctx = SpringApplication.run(MyApplication.class, args); } try { openHomePage("http://localhost:8

Windows下利用bat批量打开程序,关闭程序

打开程序 在工作中,每次开机会流程化的打开很多软件,比如:sublime text.notepad++(总觉得用notepad看txt文件比较顺眼).spyder.微信.qq……,手动挨个点太麻烦,设置为开机启动的话又太慢(由于装了Oracle,开机已经很慢了). 后来了解到可以用bat文件来封装这些操作,格式如下: start /d "文件路径" 执行文件 使用步骤: 1.新建txt文件 2.编辑内容,示例如下: start /d "D:\softwares\QQ\Bin&

Python编写简易木马程序(转载乌云)

Python编写简易木马程序 light · 2015/01/26 10:07 0x00 准备 文章内容仅供学习研究.切勿用于非法用途! 这次我们使用Python编写一个具有键盘记录.截屏以及通信功能的简易木马.依然选用Sublime text2 +JEDI(python自动补全插件)来撸代码,安装配置JEDI插件可以参照这里: /tips/?id=4413 首先准备好我们需要的依赖库,python hook和pythoncom. 下载安装python hook 下载安装pythoncom模块:

Python编写守护进程程序

Python编写守护进程程序思路 1. fork子进程,父进程退出通常,我们执行服务端程序的时候都会通过终端连接到服务器,成功连接后会加载shell环境,终端和shell都是进程,shell进程是终端进程的子进程,通过ps命令可以很容易的查看到.在这个shell环境下一开始执行的程序都是shell进程的子进程,自然会受到shell进程的影响.在程序里fork子进程后,父进程退出,对了shell进程来说,这个父进程就算执行完了,而产生的子进程会被init进程接管,从而也就脱离了终端的控制. 2-4

mtk硬件启动关闭蓝牙功能的项目:mtk 上层操作GPIO应用示例

mtk硬件启动关闭蓝牙功能的项目:mtk上层操作GPIO应用示例 项目要求: 接上篇: 1:蓝牙按键(KCOL2+KROW1)长按3秒,软件上控制GPIO144拉高2秒后关闭,蓝牙就开启并搜索配对.同时拉高GPIO98,控制音频的模拟开关切换蓝牙音源. 2:蓝牙在工作状态下,给出个1.8V的高电平,给GPIO145用来检测蓝牙的工作状态. 3:蓝牙在工作装态下想要重新配对,在长按蓝牙按键3秒,控制GPIO97拉高3秒后关闭,蓝牙模块在收到这个信号后执行清空列表和重新搜索功能. 4:蓝牙按键(KC