avatar
d*o
1
I have an Java application, say, called 'app1'. I want to write
a B shell script to invoke it. the reason to do that is to
record how many files 'app1' opened by useing 'lsof'. Problems:
1. how to record the output of 'lsof'?
(for example, if it is in Perl, I can do $output = `lsof`. what
is the counterpart in shell script?)
2. in the end of my shell script, I'll invoke the program 'app1'
by just say 'app1'. How can I use 'lsof' again _AFTER_ 'app1'
is running?
one way is to write like this:
app
avatar
p*a
2

output=`lsof`
looping=1
app1 &
while [ looping ]
do
sleep 120
output=`lsof`
echo "# of files opened: $output"
# some condition to set looping variable
...
done


【在 d*o 的大作中提到】
: I have an Java application, say, called 'app1'. I want to write
: a B shell script to invoke it. the reason to do that is to
: record how many files 'app1' opened by useing 'lsof'. Problems:
: 1. how to record the output of 'lsof'?
: (for example, if it is in Perl, I can do $output = `lsof`. what
: is the counterpart in shell script?)
: 2. in the end of my shell script, I'll invoke the program 'app1'
: by just say 'app1'. How can I use 'lsof' again _AFTER_ 'app1'
: is running?
: one way is to write like this:

avatar
d*o
3
very, very appreciate your help. Thanks a lot!

【在 p*a 的大作中提到】
:
: output=`lsof`
: looping=1
: app1 &
: while [ looping ]
: do
: sleep 120
: output=`lsof`
: echo "# of files opened: $output"
: # some condition to set looping variable

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。