d*o 发帖数: 108 | 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 | p*a 发帖数: 592 | 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:
| d*o 发帖数: 108 | 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
|
|