I have made a little script that checks for new mail in a specified folder.
I have made sure to check that the commands work when I type it from a shell:
cd Maildir/new | ls -l | wc -l
which outputs 0 which is correct since there is no new mail.
But when it gets executed in this script:
WindowTitle {FvwmMail}
WindowSize 128 24 # Taille
Font "Shadow=1:xft:Verdana:bold:pixelsize=12:minspace=true"
Init
Begin
Set $sp = {Newsss msg: }(GetOutput {cd ~/Maildir/new | ls -l | wc -l} 1 -1)
ChangeTitle 1 $sp
End
PeriodicTasks
Begin
If (RemainderOfDiv (GetTime) 5)==0 Then
Begin
Set $sp = {Newddd msg: }(GetOutput {cd ~/Maildir/new |ls -l | wc -l} 1 -1)
ChangeTitle 1 $sp
End
End
Widget 1
Property
Size 128 24
Position 0 0
Colorset 60
Font "Shadow=1:xft:Verdana:pixelsize=10:minspace=true"
Flags Center
Type ItemDraw
Title {}
End
it constantly outputs ‘26’ which is the number of files that I have in my homw dir + 1.
Why does it output the count of files in my homedir +1 instead of the number of files in Maildir/new??
It doesn’t work if I try that from the shell. I don’t think the current directory is preserved after the first pipe. Anyway, you can use this command instead:
ls ~/Maildir/new | wc -l
Note that the “-l” option to ls is not needed and causes the file count to be incremented by 1 (the “total x” line).