I'm a total noob writing scripts in Linux. I have to work on QNAP NAS. The problem is that sometimes files remains open. I have to check who opened the file. First I need to get list of open files. Every open file has an associated PID. Then I have to get domain user names by PIDs.
I have two scripts. The first lists PIDs of open files. I pass one parameter, the name of file I search for. It can generate more lines with PIDs.
The second script lists the associated domain user name for a given the PID. I have to run the second script for every PIDs listed by the first script.
I don't know how to handle in the second script the multi line output from the frist script.
Thanks for advice.
Mark
first script (smbopenfiles):
/usr/local/samba/bin/smbstatus -v|grep $1|awk '{print $1}'
second script (smbwhois):
/usr/local/samba/bin/smbstatus -v|grep $1|awk '{print $3}'|grep -v -e DENY|grep -v -e domain
script_1and then use its output as the input forscript_2, as the title suggest, I recommend reading about piping in linux. For instance,./script_1 | ./script_2../smbwhois $(./smbopenfiles Szabads)but your question could do with improving.