My Expect script looks as shown below:
my.exp:
Code:
#!/usr/bin/expect -f
set M [lindex $argv 0]
spawn echo "stats <$M>" \| debugfs.ocfs2 -n /dev/HPEVA/OCFS2
expect "END"
send "q\r"
So, I am passing a parameter to the Expect script. Since debugfs.ocfs2 will sit at the "END" prompt line I am sending it "q\r" so that it can be closed / quitted automatically.
Here is what happens when I run the above script:
Code:
./my.exp M000000000000000065702b00000000
spawn echo stats <M000000000000000065702b00000000> | debugfs.ocfs2 -n /dev/HPEVA/OCFS2
stats <M000000000000000065702b00000000> | debugfs.ocfs2 -n /dev/HPEVA/OCFS2
send: spawn id exp4 not open
while executing
"send "q\r""
(file "./my.exp" line 8)
I have been looking up the error on Google and did not find any one particular cause of "spawn id exp4 not open". I do now understand that the previous command may have crashed or too early closed for the send command to send anything to it.
Please Note: The main problem / question / requirement is we have a large number of those values M00*(M000000000000000065702b00000000) and we need to run the debugfs command for each of them. So I wrote this small for loop script and called it a wrapper script that will call the expect script passing it a new value each time:
wrapper.sh:
Code:
for M in `grep Lockres /root/fslock |grep M0 |awk '{print $2}'`; do
./my.exp $M ;
done
The debugfs command shows the output and then sits at "END" that is why I am using Expect to send it "q\r".
Can I run that for loop in Expect itself and walk through each value?
Do I need to put an extra "echo" in this line?
Code:
spawn echo echo "stats <$M>" \| debugfs.ocfs2 -n /dev/HPEVA/OCFS2
so that it becomes:
Code:
echo stats <M000000000000000065702b00000000> | debugfs.ocfs2 -n /dev/HPEVA/OCFS2
I can't test that thing right now. Actually that is what my friend wants to do and he has the system so I will have to wait until morning when he goes to office.