×

Loading...
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务
Ad by
  • 推荐 OXIO 加拿大高速网络,最低月费仅$40. 使用推荐码 RCR37MB 可获得一个月的免费服务

suppose ur application1 write to file /tmp/1.out. suppose it is ascii file and line lengh is not more than 1024Byte. or the wrapper need bo coded by C other than shell.

Step 1:Before u start application1. do "mkfifo /tmp/1.out.
Step 2:start application1.
Step 3: run the shell script:
$ wraper.sh < 1.out > 2.out

==================
#we assume the script name is wrapper.sh
while read x
do
echo $x
if [ $sentsign -ne 1 ] ; then
kill -<the signal number> <ur application2>
# for example: :)
# kill -9 $$
fi
sentsign=1
done
# end of script.
====================

Note: this script only send signal to application2 when the application1 write the first byte/line to output.
Note: it is wraper, the output of app1 is 1.out, the stream file (2.out) is from the wraper.
Note: once the app1 close its output file fd, the wraper exit automaticly.
Report

Replies, comments and Discussions:

  • 工作学习 / IT技术讨论 / 谁见过这么样的应用: 如果一个stream file 别修改,马上给一个进程发个 signal.
    • named pipe.
      • Are you sure.
        • should work. create a wrapper. the wrapper can send signal to other program. Your 1st application write output to a fifo. the wrapper read it and write to target file, in the meanwhile send signal
          • the 1 st application , in my case, is unknown.
            • if file name of the output file write by the first application is also unknown, 我就没召了。
              • 说白了就是个triger.只不过是stream file 而已。有办法吗?
                • what does stream file mean? sequence write? There are several different solution, complex or simple, depend on ur requirment(if u are in Unix enviroment)
                  • I am using Unix. "stream file" means a regular file on unix. Please help.
                    • suppose ur application1 write to file /tmp/1.out. suppose it is ascii file and line lengh is not more than 1024Byte. or the wrapper need bo coded by C other than shell.
                      Step 1:Before u start application1. do "mkfifo /tmp/1.out.
                      Step 2:start application1.
                      Step 3: run the shell script:
                      $ wraper.sh < 1.out > 2.out

                      ==================
                      #we assume the script name is wrapper.sh
                      while read x
                      do
                      echo $x
                      if [ $sentsign -ne 1 ] ; then
                      kill -<the signal number> <ur application2>
                      # for example: :)
                      # kill -9 $$
                      fi
                      sentsign=1
                      done
                      # end of script.
                      ====================

                      Note: this script only send signal to application2 when the application1 write the first byte/line to output.
                      Note: it is wraper, the output of app1 is 1.out, the stream file (2.out) is from the wraper.
                      Note: once the app1 close its output file fd, the wraper exit automaticly.
                      • Bad news! App1 is ftp.
                        • let cry on the bad news!!
                • pm me with ur phone #